Skip to content

Commit 256cbcb

Browse files
committed
Bundle the code
1 parent 9f56933 commit 256cbcb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+729
-257
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
node-version: ${{ matrix.node }}
6060

6161
- name: Test
62-
run: pnpm exec vitest --coverage
62+
run: pnpm test:all --coverage
6363

6464
- name: Submit coverage
6565
uses: coverallsapp/github-action@master

bin/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import { assertDeprecated } from '../lib/assert.js';
88
import * as defaults from '../lib/defaults.js';
99
import { concurrently } from '../lib/index.js';
1010
import { castArray } from '../lib/utils.js';
11-
import { readPackageJson } from './read-package-json.js';
11+
import { version } from '../package.json' with { type: 'json' };
1212

13-
const version = String(readPackageJson().version);
1413
const epilogue = `For documentation and more examples, visit:\nhttps://github.com/open-cli-tools/concurrently/tree/v${version}/docs`;
1514

1615
// Clean-up arguments (yargs expects only the arguments after the program name)

bin/read-package-json.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

eslint.config.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,19 @@ export default defineConfig(
2121
},
2222
},
2323
eslint.configs.recommended,
24-
tseslint.configs.recommended,
24+
tseslint.configs.recommendedTypeChecked,
25+
{
26+
languageOptions: {
27+
parserOptions: {
28+
projectService: true,
29+
tsconfigRootDir: import.meta.dirname,
30+
},
31+
},
32+
},
33+
{
34+
files: ['**/*.js', '**/*.spec.ts', '**/__fixtures__/**/*', 'tests/**/*'],
35+
extends: [tseslint.configs.disableTypeChecked],
36+
},
2537
{
2638
rules: {
2739
curly: 'error',
@@ -36,6 +48,19 @@ export default defineConfig(
3648
varsIgnorePattern: '^_',
3749
},
3850
],
51+
'@typescript-eslint/prefer-promise-reject-errors': 'off',
52+
},
53+
},
54+
{
55+
files: ['**/*.ts'],
56+
ignores: ['**/*.spec.ts', '**/__fixtures__/**/*', 'tests/**/*'],
57+
rules: {
58+
'@typescript-eslint/consistent-type-imports': 'error',
59+
'@typescript-eslint/no-import-type-side-effects': 'error',
60+
'@typescript-eslint/consistent-type-exports': [
61+
'error',
62+
{ fixMixedExportsWithInlineTypeSpecifier: true },
63+
],
3964
},
4065
},
4166
{ files: ['**/__fixtures__/**/*.{js,ts}'], rules: { 'no-console': 'off' } },
@@ -49,7 +74,7 @@ export default defineConfig(
4974
'simple-import-sort/exports': 'error',
5075
'import/first': 'error',
5176
'import/newline-after-import': 'error',
52-
'import/no-duplicates': 'error',
77+
'import/no-duplicates': ['error', { 'prefer-inline': true }],
5378
},
5479
},
5580
{

lib/command-parser/command-parser.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CommandInfo } from '../command.js';
1+
import type { CommandInfo } from '../command.js';
22

33
/**
44
* A command parser encapsulates a specific logic for mapping `CommandInfo` objects

lib/command-parser/expand-arguments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { quote } from 'shell-quote';
22

3-
import { CommandInfo } from '../command.js';
4-
import { CommandParser } from './command-parser.js';
3+
import type { CommandInfo } from '../command.js';
4+
import type { CommandParser } from './command-parser.js';
55

66
/**
77
* Replace placeholders with additional arguments.

lib/command-parser/expand-shortcut.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CommandInfo } from '../command.js';
2-
import { CommandParser } from './command-parser.js';
1+
import type { CommandInfo } from '../command.js';
2+
import type { CommandParser } from './command-parser.js';
33

44
/**
55
* Expands shortcuts according to the following table:

lib/command-parser/expand-wildcard.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import fs from 'node:fs';
22

3-
import { CommandInfo } from '../command.js';
3+
import type { CommandInfo } from '../command.js';
44
import JSONC from '../jsonc.js';
5-
import { escapeRegExp } from '../utils.js';
6-
import { CommandParser } from './command-parser.js';
5+
import { escapeRegExp, isObject } from '../utils.js';
6+
import type { CommandParser } from './command-parser.js';
77

88
// Matches a negative filter surrounded by '(!' and ')'.
99
const OMISSION = /\(!([^)]+)\)/;
@@ -14,7 +14,7 @@ const OMISSION = /\(!([^)]+)\)/;
1414
* configuration files of the current directory.
1515
*/
1616
export class ExpandWildcard implements CommandParser {
17-
static readDeno() {
17+
static readDeno(this: void): unknown {
1818
try {
1919
let json: string = '{}';
2020

@@ -30,7 +30,7 @@ export class ExpandWildcard implements CommandParser {
3030
}
3131
}
3232

33-
static readPackage() {
33+
static readPackage(this: void): unknown {
3434
try {
3535
const json = fs.readFileSync('package.json', { encoding: 'utf-8' });
3636
return JSON.parse(json);
@@ -49,18 +49,23 @@ export class ExpandWildcard implements CommandParser {
4949

5050
private relevantScripts(command: string): string[] {
5151
if (!this.packageScripts) {
52-
this.packageScripts = Object.keys(this.readPackage().scripts || {});
52+
const content = this.readPackage();
53+
const scripts =
54+
isObject(content) && isObject(content.scripts) ? Object.keys(content.scripts) : [];
55+
56+
this.packageScripts = scripts;
5357
}
5458

5559
if (command === 'deno task') {
5660
if (!this.denoTasks) {
61+
const content = this.readDeno();
62+
const tasks =
63+
isObject(content) && isObject(content.tasks) ? Object.keys(content.tasks) : [];
64+
5765
// If Deno tries to run a task that doesn't exist,
5866
// it can fall back to running a script with the same name.
5967
// Therefore, the actual list of tasks is the union of the tasks and scripts.
60-
this.denoTasks = [
61-
...Object.keys(this.readDeno().tasks || {}),
62-
...this.packageScripts,
63-
];
68+
this.denoTasks = [...tasks, ...this.packageScripts];
6469
}
6570

6671
return this.denoTasks;

lib/command-parser/strip-quotes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CommandInfo } from '../command.js';
2-
import { CommandParser } from './command-parser.js';
1+
import type { CommandInfo } from '../command.js';
2+
import type { CommandParser } from './command-parser.js';
33

44
/**
55
* Strips quotes around commands so that they can run on the current shell.

lib/command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Buffer } from 'node:buffer';
2-
import {
1+
import type { Buffer } from 'node:buffer';
2+
import type {
33
ChildProcess as BaseChildProcess,
44
MessageOptions,
55
SendHandle,
66
SpawnOptions,
77
} from 'node:child_process';
88
import process from 'node:process';
9-
import { EventEmitter, Writable } from 'node:stream';
9+
import type { EventEmitter, Writable } from 'node:stream';
1010

1111
import Rx from 'rxjs';
1212

0 commit comments

Comments
 (0)