Skip to content

Commit

Permalink
Merge pull request #3275 from felipedeboni/master
Browse files Browse the repository at this point in the history
Refactor CLI to use `npm` and `yarn` instead of third party packages
  • Loading branch information
Hypnosphi committed Mar 29, 2018
1 parent 89fd697 commit f228149
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/cli/lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path';
import fs from 'fs';
import chalk from 'chalk';
import latestVersion from 'latest-version';
import { sync as spawnSync } from 'cross-spawn';
import { gt } from 'semver';
import latestVersion from './latest_version';

import { version, devDependencies } from '../package.json';

Expand Down
17 changes: 17 additions & 0 deletions lib/cli/lib/latest_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { sync as spawnSync } from 'cross-spawn';
import hasYarn from './has_yarn';

const packageManager = hasYarn() ? 'yarn' : 'npm';

export default async function latestVersion(packageName) {
const result = spawnSync(packageManager, ['info', packageName, '--json'], {
cwd: process.cwd(),
env: process.env,
stdio: 'pipe',
encoding: 'utf-8',
silent: true,
});

const info = JSON.parse(result.output[1].toString());
return info.data.version;
}
1 change: 0 additions & 1 deletion lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"cross-spawn": "^6.0.5",
"jscodeshift": "^0.5.0",
"json5": "^0.5.1",
"latest-version": "^3.1.0",
"merge-dirs": "^0.2.1",
"semver": "^5.5.0",
"shelljs": "^0.8.1",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9234,7 +9234,7 @@ latest-version@^2.0.0:
dependencies:
package-json "^2.0.0"

latest-version@^3.0.0, latest-version@^3.1.0:
latest-version@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15"
dependencies:
Expand Down

0 comments on commit f228149

Please sign in to comment.