Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
del.promise = function delPromise(patterns, options) {
var opts = extend({cwd: process.cwd()}, options);
var deleted = [];
if (patterns === '' && isCurrentDir(opts.cwd)) {
return Promise.resolve(deleted);
}
return glob.promise(patterns, opts)
.then(function(files) {
// sync is actually faster than async most of the time
files.forEach(function(fp) {
del.sync(fp, opts);
deleted.push(fp);
});
return deleted;
});
};
if (!include.length) {
throw Error('include option should be specified');
}
const parents = include.reduce((list, pattern) => {
const parent = globParent(pattern);
if (list.indexOf(parent) === -1) {
list.push(parent);
}
return list;
}, []);
parents.forEach(parent => this.addContextDependency(parent));
return matched(patterns, { realpath: true }).then(combinePaths).then(code => done(null, code));
}
load(id) {
if (id === entry) {
if (!include.length) {
return Promise.resolve('')
}
const patterns = include.concat(exclude.map(pattern => '!' + pattern))
return matched(patterns, { realpath: true }).then(paths => paths.map(exporter).join('\n'))
}
}
}
load(id: string): ?Promise {
if (id === entry) {
if (!include.length) {
return Promise.resolve('');
}
const patterns = include.concat(exclude.map(pattern => '!' + pattern));
return matched(patterns, { realpath: true }).then(paths =>
paths.map(exporter).join('\n')
);
}
}
};
load(id) {
if (id === entry) {
if (!include.length) {
return Promise.resolve('')
}
const patterns = include.concat(exclude.map(pattern => '!' + pattern))
return matched(patterns, { realpath: true }).then(paths => {
let s =
paths.map((path, index) => `import _m${index} from ${JSON.stringify(path)}`).join(';\n') +
';\n' +
'export default [\n' +
paths.map((path, index) => `_m${index}`).join(', ') + '\n' +
'];\n'
return s
})
}
}
}