Skip to content

Commit

Permalink
chore: remove cross-spawn (#2097)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Nov 10, 2020
1 parent 363f120 commit b4289c0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
10 changes: 3 additions & 7 deletions packages/utils/__tests__/global-packages-path.test.ts
Expand Up @@ -12,7 +12,7 @@ const globalModulesNpmValue = 'test-npm';
jest.setMock('global-modules', globalModulesNpmValue);

import * as path from 'path';
import * as spawn from 'cross-spawn';
import * as execa from 'execa';

describe('getPathToGlobalPackages', () => {
it('uses global-modules if package manager is npm', () => {
Expand All @@ -22,12 +22,8 @@ describe('getPathToGlobalPackages', () => {

it('executes a command to find yarn global dir if package manager is yarn', () => {
(getPackageManager as jest.Mock).mockReturnValue('yarn');
(spawn.sync as jest.Mock).mockReturnValue({
stdout: {
toString: (): string => {
return 'test-yarn';
},
},
(execa.sync as jest.Mock).mockReturnValue({
stdout: 'test-yarn',
});
// after the yarn global dir is found, the node_modules directory
// is added on to the path
Expand Down
2 changes: 0 additions & 2 deletions packages/utils/package.json
Expand Up @@ -13,7 +13,6 @@
],
"dependencies": {
"colorette": "^1.2.1",
"cross-spawn": "^7.0.3",
"execa": "^4.1.0",
"findup-sync": "^4.0.0",
"global-modules": "^2.0.0",
Expand All @@ -28,7 +27,6 @@
"webpack-cli": "4.x.x"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/got": "^9.6.11",
"@types/prettier": "^2.1.5",
"@types/yeoman-generator": "^4.11.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/global-packages-path.ts
@@ -1,4 +1,4 @@
import spawn from 'cross-spawn';
import { sync } from 'execa';
import path from 'path';
import { utils } from 'webpack-cli';

Expand All @@ -16,7 +16,7 @@ export function getPathToGlobalPackages(): string {
const manager: string = getPackageManager();
if (manager === 'yarn') {
try {
const yarnDir = spawn.sync('yarn', ['global', 'dir']).stdout.toString().trim();
const yarnDir = sync('yarn', ['global', 'dir']).stdout;
return path.join(yarnDir, 'node_modules');
} catch (e) {
// Default to the global npm path below
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -4203,7 +4203,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"

cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
cross-spawn@^7.0.0, cross-spawn@^7.0.2:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
Expand Down

0 comments on commit b4289c0

Please sign in to comment.