Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
BowerJson.find(this._root, function(error, file) {
if (error) return next(['No bower json file found', error]);
BowerJson.read(file, function(error, info) {
if (error) return next(['Invalid bower.json', error]);
if (!(typeof info.name === 'string')) return next('package name is required');
// Make sure the name doesn't break out of our sandbox
var packageRoot = path.resolve(this._sandbox, info.name);
if (packageRoot.indexOf(this._sandbox) !== 0) {
return next('Inavlid package name: ' + info.name);
}
shelljs.mv(this._root, packageRoot);
this._root = packageRoot;
next();
}.bind(this));
}.bind(this));
};
bowerJson.find(path.resolve(options.directory, package), function(err, filename){
if (!filename){
output[package] = {licenses: 'UNKNOWN'};
completed.push(package);
return;
}
bowerJson.read(filename, function(err, bowerData){
if (!!err) {
callback(null, err);
return;
}
var moduleInfo = {licenses: []};
if (bowerData.license) moduleInfo.licenses = moduleInfo.licenses.concat(bowerData.license);
if (bowerData.repository) moduleInfo.repository = bowerData.repository;
if (bowerData.homepage) moduleInfo.homepage = bowerData.homepage;
// enhance with npm-license
npmLicense.init({start: path.resolve(options.directory, package)}, function(npmData){
var npmVersion;
if (Object.keys(npmData).length > 0)
npmVersion = Object.keys(npmData)[0].split('@')[1];
const bowerJson = await new Promise((resolve, reject) => {
const config = defaultBowerConfig({
save: false,
});
const cwd = config.cwd || process.cwd();
readBowerJson(cwd, {}, (err: {}, json: {}) => {
err ? reject(err) : resolve(json);
});
});