Skip to content

Commit

Permalink
PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jennyEckstein committed Jan 24, 2020
1 parent 069fc90 commit 7fe7557
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 32 deletions.
7 changes: 4 additions & 3 deletions bin/lifion-verify-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

const argv = require('minimist')(process.argv.slice(2));
const verifyDeps = require('../lib');
const { name } = require('../package.json');

if (argv.help) {
console.log(
[
'',
'Usage: lifion-verify-deps [options]',
`Usage: ${name} [options]`,
'',
'Checks existing dependencies for available updates',
'',
Expand All @@ -18,11 +19,11 @@ if (argv.help) {
'-u --auto-upgrade Automatically run all suggested upgrades'
].join('\n')
);
return;
}

async function run() {
const { 'auto-upgrade': autoUpgradeLong, u: autoUpgradeShort } = argv;
const autoUpgrade = autoUpgradeLong || autoUpgradeShort;
const autoUpgrade = argv['auto-upgrade'] || argv.u;
try {
await verifyDeps({ autoUpgrade, dir: process.cwd() });
process.exit(0);
Expand Down
7 changes: 3 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ function getPkgIds(filteredPkgs) {
* @param {string} [options.dir] - The path where to look for the package.json file.
* @param {object} [options.logger] - A logger instance, with a similar API as the console object.
*/

async function verifyDeps({ autoUpgrade = false, dir, logger = console } = {}) {
const { dependencies, devDependencies } = require(path.join(dir, 'package.json'));
logger.info(blue('Checking NPM module versions…\n'));
Expand All @@ -93,12 +92,12 @@ async function verifyDeps({ autoUpgrade = false, dir, logger = console } = {}) {
}

if (autoUpgrade) {
logger.info('UPGRADING...');
logger.info('UPGRADING');
logger.info(upgradePackages);
const prodResult = await execAsync(`npm i ${getPkgIds(prodPkgs)}`);
const devResult = await execAsync(`npm i -D ${getPkgIds(devPkgs)}`);
logger.info(`${green(`${bold('Upgraded Dependencies:\n')}${prodResult.stdout}`)}`);
logger.info(`${green(`${bold('Upgraded Dev Dependencies:\n')}${devResult.stdout}`)}`);
logger.info(`${green(`${bold('Upgraded dependencies:\n')}${prodResult.stdout}`)}`);
logger.info(`${green(`${bold('Upgraded development dependencies:\n')}${devResult.stdout}`)}`);
} else {
logger.info(`\n${bold('To resolve this, run:')}`);
logger.info(upgradePackages);
Expand Down
6 changes: 3 additions & 3 deletions lib/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,13 @@ describe('lib/index', () => {
3,
`${outdatedDevDep} is outdated: ${olderVersion}${newerVersion}`
);
expect(logger.info).toHaveBeenNthCalledWith(4, 'UPGRADING...');
expect(logger.info).toHaveBeenNthCalledWith(4, 'UPGRADING');
expect(logger.info).toHaveBeenNthCalledWith(
5,
`npm i ${outdatedDep}@1.0.1 \nnpm i -D ${outdatedDevDep}@1.0.1 `
);
expect(logger.info).toHaveBeenNthCalledWith(6, `Upgraded Dependencies:\n["1.0.0"]`);
expect(logger.info).toHaveBeenNthCalledWith(7, `Upgraded Dev Dependencies:\n["1.0.0"]`);
expect(logger.info).toHaveBeenNthCalledWith(6, `Upgraded dependencies:\n["1.0.0"]`);
expect(logger.info).toHaveBeenNthCalledWith(7, `Upgraded development dependencies:\n["1.0.0"]`);
});
});

Expand Down
49 changes: 28 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"auto-changelog": "^1.16.2",
"chance": "^1.1.4",
"check-engines": "^1.5.0",
"codecov": "^3.6.1",
"codecov": "^3.6.2",
"eslint": "^6.8.0",
"eslint-config-lifion": "^1.3.3",
"husky": "^3.1.0",
Expand Down

0 comments on commit 7fe7557

Please sign in to comment.