this.updates.forEach((update) => { const pkg = update.package; const packageLocation = pkg.location; const packageJsonLocation = path.join(packageLocation, "package.json"); // set new version pkg.version = this.updatesVersions[pkg.name] || pkg.version; // update pkg dependencies this.updatePackageDepsObject(pkg, "dependencies", exact); this.updatePackageDepsObject(pkg, "devDependencies", exact); this.updatePackageDepsObject(pkg, "peerDependencies", exact); // write new package writePkg.sync(packageJsonLocation, pkg.toJSON()); // NOTE: Object.prototype.toJSON() is normally called when passed to // JSON.stringify(), but write-pkg iterates Object.keys() before serializing // so it has to be explicit here (otherwise it mangles the instance properties) // we can now generate the Changelog, based on the // the updated version that we're about to release. if (this.options.conventionalCommits) { ConventionalCommitUtilities.updateChangelog({ name: pkg.name, location: pkg.location }, this.execOpts); changedFiles.push(ConventionalCommitUtilities.changelogLocation(pkg)); } // push to be git committed changedFiles.push(packageJsonLocation); });
var post = function () { // for personal use if (cli.indexOf('--unicorn') !== -1) { var pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) pkg.devDependencies.mos = '*' writePkg.sync(pkgPath, pkg) } }
const post = () => { // For personal use if (cli.indexOf('--unicorn') !== -1) { const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); pkg.devDependencies.ava = '*'; writePkg.sync(pkgPath, pkg); } };
module.exports = function (opts) { opts = opts || {} var ret = readPkgUp.sync({ cwd: opts.cwd, normalize: false, }) var pkg = ret.pkg || {} var pkgPath = ret.path || path.resolve(opts.cwd || '', 'package.json') var cli = opts.args || argv() var args = arrExclude(cli, ['--init', '--unicorn']) var cmd = 'mos' + (args.length > 0 ? ' ' + args.join(' ') : '') var s = pkg.scripts = pkg.scripts ? pkg.scripts : {} if (s.test && s.test !== DEFAULT_TEST_SCRIPT) { s.test = s.test.replace(/\bnode (test\/)?test\.js\b/, cmd) if (!/\bmos\b/.test(s.test)) { s.test += ' && ' + cmd } } else { s.test = cmd } s.md = 'mos' s['?md'] = 'echo "Update the markdown files"' writePkg.sync(pkgPath, pkg) var post = function () { // for personal use if (cli.indexOf('--unicorn') !== -1) { var pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) pkg.devDependencies.mos = '*' writePkg.sync(pkgPath, pkg) } } if (opts.skipInstall) { post() return Promise.resolve() } var child = childProcess.spawn('npm', ['install', '--save-dev', 'mos'], { cwd: path.dirname(pkgPath), stdio: 'inherit', }) return new Promise(function (resolve, reject) { child.on('error', reject) child.on('exit', function (code) { if (code) { reject(new Error('npm command exited with non-zero exit code')) } post() resolve() }) }) }
module.exports = opts => { opts = opts || {}; const ret = readPkgUp.sync({ cwd: opts.cwd, normalize: false }); const pkg = ret.pkg || {}; const pkgPath = ret.path || path.resolve(opts.cwd || process.cwd(), 'package.json'); const pkgCwd = path.dirname(pkgPath); const cli = opts.args || process.argv.slice(2); const args = arrExclude(cli, ['--init', '--unicorn']); const cmd = 'ava' + (args.length > 0 ? ' ' + args.join(' ') : ''); const s = pkg.scripts = pkg.scripts ? pkg.scripts : {}; if (s.test && s.test !== DEFAULT_TEST_SCRIPT) { s.test = s.test.replace(/\bnode (test\/)?test\.js\b/, cmd); if (!/\bava\b/.test(s.test)) { s.test += ` && ${cmd}`; } } else { s.test = cmd; } writePkg.sync(pkgPath, pkg); const post = () => { // For personal use if (cli.indexOf('--unicorn') !== -1) { const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); pkg.devDependencies.ava = '*'; writePkg.sync(pkgPath, pkg); } }; if (opts.skipInstall) { return Promise.resolve(post); } if (hasYarn(pkgCwd)) { return execa('yarn', ['add', '--dev', 'ava'], {cwd: pkgCwd}).then(post); } return execa('npm', ['install', '--save-dev', 'ava'], { cwd: pkgCwd, stdio: 'inherit' }).then(post); };