Skip to content

Commit fed0ccf

Browse files
authored
Replace execa with nano-spawn (#2541)
1 parent c5aa72c commit fed0ccf

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@
9393
"eslint-remote-tester": "^4.0.1",
9494
"eslint-remote-tester-repositories": "^2.0.0",
9595
"espree": "^10.3.0",
96-
"execa": "^9.5.2",
9796
"listr2": "^8.2.5",
9897
"lodash-es": "^4.17.21",
9998
"markdownlint-cli": "^0.43.0",
10099
"memoize": "^10.0.0",
100+
"nano-spawn": "^0.2.0",
101101
"node-style-text": "^0.0.7",
102102
"npm-package-json-lint": "^8.0.0",
103103
"npm-run-all2": "^7.0.2",
104+
"open-editor": "^5.1.0",
104105
"outdent": "^0.8.0",
105106
"pretty-ms": "^9.2.0",
106107
"typescript": "^5.7.3",

scripts/create-rule.js

+18-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import path from 'node:path';
44
import {fileURLToPath} from 'node:url';
55
import enquirer from 'enquirer';
66
import {template} from 'lodash-es';
7-
import {execa} from 'execa';
7+
import openEditor from 'open-editor';
8+
import spawn from 'nano-spawn';
89

910
const dirname = path.dirname(fileURLToPath(import.meta.url));
1011
const ROOT = path.join(dirname, '..');
@@ -116,12 +117,20 @@ renderTemplate({
116117
data,
117118
});
118119

120+
const filesToOpen = [
121+
`docs/rules/${id}.md`,
122+
`rules/${id}.js`,
123+
`test/${id}.js`,
124+
];
119125
try {
120-
await execa('code', [
121-
'--new-window',
122-
'.',
123-
`docs/rules/${id}.md`,
124-
`rules/${id}.js`,
125-
`test/${id}.js`,
126-
], {cwd: ROOT});
127-
} catch {}
126+
await openEditor(filesToOpen);
127+
} catch {
128+
// https://github.com/sindresorhus/open-editor/issues/15
129+
try {
130+
await spawn('code', [
131+
'--new-window',
132+
'.',
133+
...filesToOpen,
134+
], {cwd: ROOT});
135+
} catch {}
136+
}

test/integration/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import fs from 'node:fs';
44
import path from 'node:path';
55
import {parseArgs} from 'node:util';
66
import {Listr} from 'listr2';
7-
import {execa} from 'execa';
7+
import spawn from 'nano-spawn';
88
import styleText from 'node-style-text';
99
import {outdent} from 'outdent';
1010
import {isCI} from 'ci-info';
@@ -62,7 +62,7 @@ if (projects.length === 0) {
6262
}
6363

6464
const getBranch = memoize(async dirname => {
65-
const {stdout} = await execa('git', ['branch', '--show-current'], {cwd: dirname});
65+
const {stdout} = await spawn('git', ['branch', '--show-current'], {cwd: dirname});
6666
return stdout;
6767
});
6868

@@ -71,7 +71,7 @@ const execute = project => new Listr(
7171
{
7272
title: 'Cloning',
7373
skip: () => fs.existsSync(project.location) ? 'Project already downloaded.' : false,
74-
task: () => execa('git', [
74+
task: () => spawn('git', [
7575
'clone',
7676
project.repository,
7777
'--single-branch',

0 commit comments

Comments
 (0)