Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:

- run: npm run lint

- run: npm run typecheck

unit:
runs-on: ${{ matrix.os }}
timeout-minutes: 15
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ Exactly the same way as node's [`spawn`](https://nodejs.org/api/child_process.ht


```js
const spawn = require('cross-spawn');
import { spawn, spawnSync } from 'cross-spawn';

// Spawn NPM asynchronously
const child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });

// Spawn NPM synchronously
const result = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
const result = spawnSync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' });
```

`cross-spawn` is an ES module, which CommonJS code can load with `require()` too:

```js
const { spawn, spawnSync } = require('cross-spawn');
```


Expand Down Expand Up @@ -100,8 +106,11 @@ Remember to always test your code on Windows!
```sh
npm test

# TypeScript types
npm run typecheck

# During development, in watch mode
node --test --watch "test/*.test.js" "lib/**/*.test.js"
node --test --watch "test/*.test.js" "src/**/*.test.js"
```


Expand Down
25 changes: 12 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const js = require('@eslint/js');
const globals = require('globals');
import js from '@eslint/js';
import globals from 'globals';

const styleRules = {
strict: ['error', 'global'],
Expand All @@ -23,31 +21,32 @@ const styleRules = {
'no-unused-vars': ['error', { args: 'after-used', caughtErrors: 'none' }],
};

// Unit tests live next to the code they test, e.g. `lib/util/escape.test.js`, while `test/` keeps the end-to-end tests
const testFiles = ['test/**/*.js', 'lib/**/*.test.js'];
// Unit tests live next to the code they test, e.g. `src/util/escape.test.js`, while `test/` keeps the end-to-end tests
const testFiles = ['test/**/*.js', 'src/**/*.test.js'];

module.exports = [
// ESLint requires the config to be the default export
export default [
{
ignores: ['coverage/', 'test/tmp/', 'test/fixtures/(*'],
},
js.configs.recommended,
{
// Runtime code must keep working on the Node versions declared in `engines`
files: ['index.js', 'lib/**/*.js'],
ignores: ['lib/**/*.test.js'],
files: ['src/**/*.js'],
ignores: ['src/**/*.test.js'],
languageOptions: {
ecmaVersion: 2024,
sourceType: 'commonjs',
globals: globals.node,
sourceType: 'module',
globals: globals.nodeBuiltin,
},
rules: styleRules,
},
{
files: ['eslint.config.js', ...testFiles],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'commonjs',
globals: globals.node,
sourceType: 'module',
globals: globals.nodeBuiltin,
},
rules: styleRules,
},
Expand Down
Loading