Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function resolve(filepath, filenames, root = path.parse(filepath).root) {
filepath = path.dirname(filepath);
// Don't traverse above the module root
if (filepath === root || path.basename(filepath) === 'node_modules') {
return null;
}
for (const filename of filenames) {
let file = path.join(filepath, filename);
let exists = existsCache.has(file)
? existsCache.get(file)
: await fs.exists(file);
if (exists) {
existsCache.set(file, true);
return file;
}
}
return resolve(filepath, filenames, root);
}
async function resolve(filepath, filenames, root = path.parse(filepath).root) {
filepath = path.dirname(filepath);
// Don't traverse above the module root
if (filepath === root || path.basename(filepath) === 'node_modules') {
return null;
}
for (const filename of filenames) {
let file = path.join(filepath, filename);
let exists = existsCache.has(file)
? existsCache.get(file)
: await fs.exists(file);
if (exists) {
existsCache.set(file, true);
return file;
}
}
return resolve(filepath, filenames, root);
}
Array.from(b.assets).sort()[0].basename
? -1
: 1
);
assert.equal(
bundle.childBundles.size,
childBundles.length,
'expected number of child bundles mismatched'
);
await Promise.all(
childBundles.map((b, i) => assertBundleTree(children[i], b))
);
}
if (/js|css/.test(bundle.type)) {
assert(await fs.exists(bundle.name), 'expected file does not exist');
}
}
async getZip() {
const zip = new JSZip();
for (let f of await fastGlob('/src/*')) {
zip.file(f, await fs.readFile(f, 'utf8'));
}
if (await fs.exists('/dist')) {
for (let f of await fastGlob('/dist/**/*')) {
zip.file(f, await fs.readFile(f, 'utf8'));
}
}
return zip.generateAsync({type: 'uint8array'});
}
}