Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var baseDir;
if (Array.isArray(options.baseDir)) {
baseDir = options.baseDir[0];
if (options.baseDir.length > 1) {
console.warn("Checking multiple directories is not yet supported for Bower projects.\n" +
"Checking only the first directory: " + baseDir);
}
}
if (!jetpack.exists(path.join(baseDir, 'bower.json'))) {
console.log('this does not look like a Bower project, skipping Bower checks.');
return [];
}
bower.config.cwd = baseDir;
var bowerComponentsDir = path.join(bower.config.cwd, bower.config.directory);
return jetpack.inspectTreeAsync(bowerComponentsDir, { relativePath: true })
.then((result) => {
/**
* for each component, try to calculate the license from the NPM package info
* if it is a available because license-checker more closely aligns with our
* objective.
*/
return bluebird.map(result.children, (component) => {
var absPath = path.join(bowerComponentsDir, component.relativePath);
// npm license check didn't work
// try to get the license and package info from .bower.json first
// because it has more metadata than the plain bower.json
var package = '';
try {
package = jetpack.read(path.join(absPath, '.bower.json'), 'json');
export async function deleteArchive (key) {
const path = getArchiveMetaPath(key)
const info = await jetpack.inspectTreeAsync(path)
await Promise.all([
db.run(`DELETE FROM archives WHERE key=?`, key),
db.run(`DELETE FROM archives_meta WHERE key=?`, key),
jetpack.removeAsync(path)
])
return info ? info.size : 0
}
exports.deleteArchive = async function (key) {
const path = getArchiveMetaPath(key)
const info = await jetpack.inspectTreeAsync(path)
await Promise.all([
db.run(`DELETE FROM archives WHERE key=?`, key),
db.run(`DELETE FROM archives_meta WHERE key=?`, key),
db.run(`DELETE FROM archives_meta_type WHERE key=?`, key),
jetpack.removeAsync(path),
jetpack.removeAsync(getInternalLocalSyncPath(key))
])
return info.size
}
export async function deleteArchive (key) {
const path = getArchiveMetaPath(key)
const info = await jetpack.inspectTreeAsync(path)
await Promise.all([
db.run(`DELETE FROM archives WHERE key=?`, key),
db.run(`DELETE FROM archives_meta WHERE key=?`, key),
db.run(`DELETE FROM archives_meta_type WHERE key=?`, key),
jetpack.removeAsync(path)
])
return info.size
}