Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parsePkg: function* () {
var args = this.args;
// Parse pkg
var pkg = new Package(args.cwd, {
ignore: args.ignore,
skip: args.skip,
moduleDir: spmrc.get('install.path'),
entry: args.entry
});
args.pkg = pkg;
log.debug('package', 'analyse infomation');
log.debug('package', 'dependencies: ' + Object.keys(pkg.dependencies));
log.debug('package', 'files: ' + Object.keys(pkg.files));
// Get files to build
var files = args.entry.length ? args.entry : getFiles(pkg);
log.info('output', 'files: ' + files);
// Check duplicate
var dups = getDuplicate(files, pkg);
function build(args, cb) {
// add package info
try {
var pkg = new Package(args.cwd, {
skip: args.skip || [],
ignore: args.ignore || [],
moduleDir: spmrc.get('install.path')
});
if (!args.noPkgLog) {
log.info('package', 'analyse infomation');
log.info('package', 'dependencies: ' + Object.keys(pkg.dependencies));
log.info('package', 'files: ' + Object.keys(pkg.files));
}
args.pkg = pkg;
} catch(err) {
return cb(err);
}
// get build files
var files = getFiles(pkg);
util.getPackage = function(root) {
var file = join(root, 'package.json');
if (!fs.existsSync(file)) {
return null;
}
var mtime = +new Date(fs.statSync(file).mtime);
var data = pkgCache[root];
if (!data || data.mtime !== mtime) {
var pkg;
try {
var originPkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
var args = mixarg(originPkg && originPkg.spm && originPkg.spm.buildArgs || '');
pkg = new Package(root, {
moduleDir: getModuleDir(root),
skip: Object.keys(getGlobal(args.global))
});
} catch(e) {
console.error(chalk.red('Package Parse Error:'), e.message);
return null;
}
data = pkgCache[root] = {
mtime: mtime,
pkg: pkg
};
}
return data.pkg;
};
exports.getSourceFiles = function(root) {
var pkg = new Package(root || process.cwd(), {
moduleDir: spmrc.get('install.path')
});
return Object.keys(pkg.files).map(function(file) {
return file.replace(/\.js$/, '');
});
};