Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(utils): remove cross-spawn #2097

Merged
merged 1 commit into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions packages/utils/__tests__/global-packages-path.test.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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