Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
// Path to promzard config file
var promzardConfig;
ctx.config = npmConfig;
// Default to auto config
promzardConfig = path.join(resources, 'init-default.js');
if (options.interactive) {
promzardConfig = path.join(resources, 'init-config.js');
}
// Init promozard with appropriate config.
var pz = new PZ(promzardConfig, ctx);
// On data resolve the promise with data
pz.on('data', data => {
if (!pkg) {
pkg = {};
}
Object.keys(data).forEach(function(k) {
if (data[k] !== undefined && data[k] !== null) {
pkg[k] = data[k];
}
});
log.info('Created "package.json".');
resolve(data);
});
if (er) pkg = {}
else pkg = d
ctx.filename = packageFile
ctx.dirname = path.dirname(packageFile)
ctx.basename = path.basename(ctx.dirname)
if (!pkg.version || !semver.valid(pkg.version))
delete pkg.version
ctx.package = pkg
ctx.config = config || {}
// make sure that the input is valid.
// if not, use the default
var pz = new PZ(input, ctx)
pz.backupFile = def
pz.on('error', cb)
pz.on('data', function (data) {
Object.keys(data).forEach(function (k) {
if (data[k] !== undefined && data[k] !== null) pkg[k] = data[k]
})
// only do a few of these.
// no need for mans or contributors if they're in the files
var es = readJson.extraSet
readJson.extraSet = es.filter(function (fn) {
return fn.name !== 'authors' && fn.name !== 'mans'
})
readJson.extras(packageFile, pkg, function (er, pkg) {
readJson.extraSet = es
if (er) return cb(er, pkg)
if (er) pkg = {}
else pkg = d
ctx.filename = packageFile
ctx.dirname = path.dirname(packageFile)
ctx.basename = path.basename(ctx.dirname)
if (!pkg.version || !semver.valid(pkg.version))
delete pkg.version
ctx.package = pkg
ctx.config = config || {}
// make sure that the input is valid.
// if not, use the default
var pz = new PZ(input, ctx)
pz.backupFile = def
pz.on('error', cb)
pz.on('data', function (data) {
Object.keys(data).forEach(function (k) {
if (data[k] !== undefined && data[k] !== null) pkg[k] = data[k]
})
// only do a few of these.
// no need for mans or contributors if they're in the files
var es = readJson.extraSet
readJson.extraSet = es.filter(function (fn) {
return fn.name !== 'authors' && fn.name !== 'mans'
})
readJson.extras(packageFile, pkg, function (er, pkg) {
readJson.extraSet = es
if (er) return cb(er, pkg)