@plugjs/plug 0.0.9 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/files.cjs +1 -1
- package/dist/files.cjs.map +1 -1
- package/dist/files.mjs +2 -2
- package/dist/files.mjs.map +1 -1
- package/dist/fork.cjs +1 -1
- package/dist/fork.cjs.map +1 -1
- package/dist/fork.mjs +2 -2
- package/dist/fork.mjs.map +1 -1
- package/dist/helpers.cjs +12 -2
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.mjs +15 -2
- package/dist/helpers.mjs.map +1 -1
- package/dist/paths.cjs +7 -7
- package/dist/paths.cjs.map +1 -1
- package/dist/paths.mjs +5 -5
- package/dist/paths.mjs.map +1 -1
- package/dist/plugs/esbuild/fix-extensions.cjs +6 -6
- package/dist/plugs/esbuild/fix-extensions.cjs.map +2 -2
- package/dist/plugs/esbuild/fix-extensions.mjs +7 -7
- package/dist/plugs/esbuild/fix-extensions.mjs.map +2 -2
- package/dist/plugs/eslint/runner.cjs +2 -2
- package/dist/plugs/eslint/runner.cjs.map +1 -1
- package/dist/plugs/eslint/runner.mjs +3 -3
- package/dist/plugs/eslint/runner.mjs.map +1 -1
- package/dist/plugs/exec.cjs +3 -3
- package/dist/plugs/exec.cjs.map +1 -1
- package/dist/plugs/exec.mjs +4 -4
- package/dist/plugs/exec.mjs.map +1 -1
- package/dist/plugs/tsc/runner.cjs +2 -2
- package/dist/plugs/tsc/runner.cjs.map +1 -1
- package/dist/plugs/tsc/runner.mjs +3 -3
- package/dist/plugs/tsc/runner.mjs.map +1 -1
- package/dist/run.cjs +7 -13
- package/dist/run.cjs.map +1 -1
- package/dist/run.mjs +9 -15
- package/dist/run.mjs.map +1 -1
- package/package.json +6 -5
- package/src/files.ts +2 -2
- package/src/fork.ts +2 -2
- package/src/helpers.ts +19 -2
- package/src/paths.ts +3 -3
- package/src/plugs/esbuild/fix-extensions.ts +3 -3
- package/src/plugs/eslint/runner.ts +3 -3
- package/src/plugs/exec.ts +4 -4
- package/src/plugs/tsc/runner.ts +3 -3
- package/src/run.ts +12 -14
- package/types/helpers.d.ts +5 -1
- package/types/paths.d.ts +2 -2
- package/types/run.d.ts +1 -1
package/dist/plugs/exec.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { spawn } from "node:child_process";
|
|
|
5
5
|
import { assert } from "../assert.mjs";
|
|
6
6
|
import { currentRun } from "../async.mjs";
|
|
7
7
|
import { $p, logOptions } from "../log.mjs";
|
|
8
|
-
import { getCurrentWorkingDirectory,
|
|
8
|
+
import { getCurrentWorkingDirectory, resolveDirectory } from "../paths.mjs";
|
|
9
9
|
import { install } from "../pipe.mjs";
|
|
10
10
|
import { parseOptions } from "../utils/options.mjs";
|
|
11
11
|
var Exec = class {
|
|
@@ -44,13 +44,13 @@ async function spawnChild(cmd, args, options = {}, run) {
|
|
|
44
44
|
...extraOptions
|
|
45
45
|
} = options;
|
|
46
46
|
const childCwd = cwd ? run.resolve(cwd) : getCurrentWorkingDirectory();
|
|
47
|
-
assert(
|
|
47
|
+
assert(resolveDirectory(childCwd), `Current working directory ${$p(childCwd)} does not exist`);
|
|
48
48
|
const childPaths = [];
|
|
49
49
|
const baseNodePath = run.resolve("@node_modules", ".bin");
|
|
50
|
-
if (
|
|
50
|
+
if (resolveDirectory(baseNodePath))
|
|
51
51
|
childPaths.push(baseNodePath);
|
|
52
52
|
const buildNodePath = run.resolve("./node_modules", ".bin");
|
|
53
|
-
if (
|
|
53
|
+
if (resolveDirectory(buildNodePath))
|
|
54
54
|
childPaths.push(buildNodePath);
|
|
55
55
|
const extraPath = env.PATH || process.env.PATH;
|
|
56
56
|
if (extraPath)
|
package/dist/plugs/exec.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/plugs/exec.ts"],
|
|
4
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,OAAO,eAAe;A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UAAU,gBAAgB,MAAM,MAAM;AAClD,QAAI,GAAG,QAAQ,CAAC,SAAS,OAAO,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,KAAK,MAAQ,CAAC;AAAA,EAC7E;AAGA,SAAO,IAAI,QAAc,CAAC,SAAS,WAAW;AAC5C,UAAM,GAAG,SAAS,CAAC,UAAU,OAAO,KAAK,CAAC;AAC1C,UAAM,GAAG,QAAQ,CAAC,MAAM,WAAW;AACjC,UAAI,SAAS;AAAG,eAAO,QAAQ;AAC/B,UAAI;AAAQ,eAAO,OAAO,IAAI,MAAM,oCAAoC,QAAQ,CAAC;AACjF,UAAI;AAAM,eAAO,OAAO,IAAI,MAAM,kCAAkC,MAAM,CAAC;AAC3E,aAAO,IAAI,MAAM,4CAA4C,CAAC;AAAA,IAChE,CAAC;AAAA,EACH,CAAC;AACH;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -49,8 +49,8 @@ var Tsc = class {
|
|
|
49
49
|
const baseDir = run.resolve(".");
|
|
50
50
|
const report = run.report("TypeScript Report");
|
|
51
51
|
const overrides = { ...this._options };
|
|
52
|
-
const sourcesConfig = (0, import_paths.
|
|
53
|
-
const tsconfig = this._tsconfig ? run.resolve(this._tsconfig) : sourcesConfig || (0, import_paths.
|
|
52
|
+
const sourcesConfig = (0, import_paths.resolveFile)(files.directory, "tsconfig.json");
|
|
53
|
+
const tsconfig = this._tsconfig ? run.resolve(this._tsconfig) : sourcesConfig || (0, import_paths.resolveFile)(run.resolve("tsconfig.json"));
|
|
54
54
|
let rootDir;
|
|
55
55
|
if (overrides.rootDir) {
|
|
56
56
|
rootDir = overrides.rootDir = run.resolve(overrides.rootDir);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugs/tsc/runner.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAA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AAQ,aAAO,KAAK,IAAI;AAGnC,UAAM,UAAU,QAAQ,MAAM;AAC9B,mBAAI,KAAK,gBAAgB,QAAQ,QAAQ,kBAAc,eAAG,QAAQ,SAAS,CAAC;AAC5E,WAAO;AAAA,EACT;AACF;",
|
|
5
5
|
"names": ["import_options", "ts", "failures"]
|
|
6
6
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { failure } from "../../assert.mjs";
|
|
4
4
|
import { $p, log } from "../../log.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { resolveFile } from "../../paths.mjs";
|
|
6
6
|
import { parseOptions } from "../../utils/options.mjs";
|
|
7
7
|
import { TypeScriptHost } from "./compiler.mjs";
|
|
8
8
|
import { getCompilerOptions } from "./options.mjs";
|
|
@@ -19,8 +19,8 @@ var Tsc = class {
|
|
|
19
19
|
const baseDir = run.resolve(".");
|
|
20
20
|
const report = run.report("TypeScript Report");
|
|
21
21
|
const overrides = { ...this._options };
|
|
22
|
-
const sourcesConfig =
|
|
23
|
-
const tsconfig = this._tsconfig ? run.resolve(this._tsconfig) : sourcesConfig ||
|
|
22
|
+
const sourcesConfig = resolveFile(files.directory, "tsconfig.json");
|
|
23
|
+
const tsconfig = this._tsconfig ? run.resolve(this._tsconfig) : sourcesConfig || resolveFile(run.resolve("tsconfig.json"));
|
|
24
24
|
let rootDir;
|
|
25
25
|
if (overrides.rootDir) {
|
|
26
26
|
rootDir = overrides.rootDir = run.resolve(overrides.rootDir);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugs/tsc/runner.ts"],
|
|
4
|
-
"mappings": ";AAAA,OAAO,QAAQ;AAEf,SAAS,eAAe;AAExB,SAAS,IAAI,WAAW;AACxB,SAAuB,
|
|
4
|
+
"mappings": ";AAAA,OAAO,QAAQ;AAEf,SAAS,eAAe;AAExB,SAAS,IAAI,WAAW;AACxB,SAA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6
|
}
|
package/dist/run.cjs
CHANGED
|
@@ -24,7 +24,6 @@ __export(run_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(run_exports);
|
|
26
26
|
var import_node_path = require("node:path");
|
|
27
|
-
var import_assert = require("./assert.cjs");
|
|
28
27
|
var import_files = require("./files.cjs");
|
|
29
28
|
var import_log = require("./log.cjs");
|
|
30
29
|
var import_paths = require("./paths.cjs");
|
|
@@ -48,19 +47,14 @@ var RunImpl = class {
|
|
|
48
47
|
report(title) {
|
|
49
48
|
return (0, import_log.createReport)(title, this.taskName);
|
|
50
49
|
}
|
|
51
|
-
resolve(...paths) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return this.buildDir;
|
|
55
|
-
if (path.startsWith("@")) {
|
|
56
|
-
const components = (0, import_node_path.normalize)(path.substring(1)).split(import_node_path.sep);
|
|
57
|
-
const relative = (0, import_node_path.join)(...components);
|
|
58
|
-
(0, import_assert.assert)(!(0, import_paths.isAbsolutePath)(relative), `Path "${path.substring(1)}" is absolute`);
|
|
59
|
-
return (0, import_paths.resolveAbsolutePath)(this.buildDir, relative);
|
|
50
|
+
resolve(path, ...paths) {
|
|
51
|
+
if (path && path.startsWith("@")) {
|
|
52
|
+
const components = path.substring(1).split(import_node_path.sep).filter((s) => !!s);
|
|
53
|
+
return (0, import_paths.resolveAbsolutePath)(this.buildDir, ...components, ...paths);
|
|
60
54
|
}
|
|
61
|
-
if (
|
|
62
|
-
return
|
|
63
|
-
return (0, import_paths.resolveAbsolutePath)((0, import_paths.getCurrentWorkingDirectory)(), path);
|
|
55
|
+
if (!path)
|
|
56
|
+
return (0, import_paths.getCurrentWorkingDirectory)();
|
|
57
|
+
return (0, import_paths.resolveAbsolutePath)((0, import_paths.getCurrentWorkingDirectory)(), path, ...paths);
|
|
64
58
|
}
|
|
65
59
|
files(first, ...paths) {
|
|
66
60
|
if (typeof first === "string") {
|
package/dist/run.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|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AAM,QAAQ,KAAK;AAAA,IAC5B,OAAO;AACL,aAAO,mBAAM,QAAQ,KAAK,QAAQ,CAAC;AAAA,IACrC;AAAA,EACF;AAAA,EAEA,KAAK,SAAiB,MAAwD;AAC5E,UAAM,EAAE,QAAQ,SAAS,EAAE,cAAc,QAAQ,EAAE,QAAI,6BAAa,MAAM,CAAC,CAAC;AAE5E,UAAM,UAAU,QAAQ,QAAQ,EAAE,KAAK,YAAY;AACjD,YAAM,UAAU,KAAK,MAAM,aAAa,GAAG;AAC3C,uBAAiB,YAAQ,kBAAK,QAAQ,WAAW,CAAE,MAAM,GAAG,MAAO,GAAG,OAAO,GAAG;AAC9E,gBAAQ,UAAU,IAAI;AAAA,MACxB;AACA,aAAO,QAAQ,MAAM;AAAA,IACvB,CAAC;AAED,WAAO,KAAK,KAAK,OAAO;AAAA,EAC1B;AAAA,EAEA,KAAK,OAAsD;AACzD,WAAO,IAAI,qBAAS,OAAO,IAAI;AAAA,EACjC;AAAA,EAEA,KAAK,MAA0C;AAC7C,UAAM,IAAI,MAAM,wBAAwB,OAAO;AAAA,EACjD;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/run.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// run.ts
|
|
2
|
-
import {
|
|
3
|
-
import { assert } from "./assert.mjs";
|
|
2
|
+
import { sep } from "node:path";
|
|
4
3
|
import { Files } from "./files.mjs";
|
|
5
4
|
import { createReport, getLevelNumber, getLogger } from "./log.mjs";
|
|
6
|
-
import { getCurrentWorkingDirectory,
|
|
5
|
+
import { getCurrentWorkingDirectory, resolveAbsolutePath } from "./paths.mjs";
|
|
7
6
|
import { PipeImpl } from "./pipe.mjs";
|
|
8
7
|
import { parseOptions } from "./utils/options.mjs";
|
|
9
8
|
import { walk } from "./utils/walk.mjs";
|
|
@@ -24,19 +23,14 @@ var RunImpl = class {
|
|
|
24
23
|
report(title) {
|
|
25
24
|
return createReport(title, this.taskName);
|
|
26
25
|
}
|
|
27
|
-
resolve(...paths) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return this.buildDir;
|
|
31
|
-
if (path.startsWith("@")) {
|
|
32
|
-
const components = normalize(path.substring(1)).split(sep);
|
|
33
|
-
const relative = join(...components);
|
|
34
|
-
assert(!isAbsolutePath(relative), `Path "${path.substring(1)}" is absolute`);
|
|
35
|
-
return resolveAbsolutePath(this.buildDir, relative);
|
|
26
|
+
resolve(path, ...paths) {
|
|
27
|
+
if (path && path.startsWith("@")) {
|
|
28
|
+
const components = path.substring(1).split(sep).filter((s) => !!s);
|
|
29
|
+
return resolveAbsolutePath(this.buildDir, ...components, ...paths);
|
|
36
30
|
}
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
39
|
-
return resolveAbsolutePath(getCurrentWorkingDirectory(), path);
|
|
31
|
+
if (!path)
|
|
32
|
+
return getCurrentWorkingDirectory();
|
|
33
|
+
return resolveAbsolutePath(getCurrentWorkingDirectory(), path, ...paths);
|
|
40
34
|
}
|
|
41
35
|
files(first, ...paths) {
|
|
42
36
|
if (typeof first === "string") {
|
package/dist/run.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/run.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,
|
|
4
|
+
"mappings": ";AAAA,SAAS,WAAW;AACpB,SAAS,aAA2B;AACpC,SAAS,cAAc,gBAAgB,iBAAiD;AACxF,SAAuB,4BAA4B,2BAA2B;AAC9E,SAAe,gBAAgB;AAC/B,SAAuB,oBAAoB;AAC3C,SAAS,YAAyB;AAgF3B,IAAM,UAAN,MAA6B;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIT,YAAY,EAAE,UAAU,UAAU,WAAW,IAAI,GAA2B;AAC1E,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,MAAM,OAAO,UAAU,QAAQ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D,WAAO,IAAI,SAAS,OAAO,IAAI;AAAA,EACjC;AAAA,EAEA,KAAK,MAA0C;AAC7C,UAAM,IAAI,MAAM,wBAAwB,OAAO;AAAA,EACjD;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugjs/plug",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"author": "",
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@babel/parser": "^7.18.
|
|
32
|
-
"@babel/types": "^7.18.
|
|
31
|
+
"@babel/parser": "^7.18.13",
|
|
32
|
+
"@babel/types": "^7.18.13",
|
|
33
33
|
"@plugjs/cov8-html": "^0.0.1",
|
|
34
34
|
"@types/node": "<17",
|
|
35
35
|
"diff": "^5.1.0",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"yargs-parser": "^21.1.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
+
"@plugjs/eslint-plugin": "^0.0.2",
|
|
45
46
|
"@types/chai": "^4.3.3",
|
|
46
47
|
"@types/diff": "^5.0.2",
|
|
47
48
|
"@types/eslint": "^8.4.6",
|
|
@@ -49,8 +50,8 @@
|
|
|
49
50
|
"@types/ms": "^0.7.31",
|
|
50
51
|
"@types/picomatch": "^2.3.0",
|
|
51
52
|
"@types/yargs-parser": "^21.0.0",
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
53
|
-
"@typescript-eslint/parser": "^5.
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
|
54
|
+
"@typescript-eslint/parser": "^5.34.0",
|
|
54
55
|
"chai": "^4.3.6",
|
|
55
56
|
"eslint-config-google": "^0.14.0"
|
|
56
57
|
}
|
package/src/files.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from './assert.js'
|
|
2
|
-
import { AbsolutePath, assertRelativeChildPath, getAbsoluteParent,
|
|
2
|
+
import { AbsolutePath, assertRelativeChildPath, getAbsoluteParent, resolveFile, resolveAbsolutePath } from './paths.js'
|
|
3
3
|
import { mkdir, writeFile } from './utils/asyncfs.js'
|
|
4
4
|
|
|
5
5
|
/** The {@link FilesBuilder} interface defines a builder for {@link Files}. */
|
|
@@ -102,7 +102,7 @@ export class Files {
|
|
|
102
102
|
const relative = assertRelativeChildPath(instance.directory, file)
|
|
103
103
|
const resolved = resolveAbsolutePath(instance.directory, file)
|
|
104
104
|
|
|
105
|
-
assert(
|
|
105
|
+
assert(resolveFile(resolved), `File "${resolved}" does not exist`)
|
|
106
106
|
set.add(relative)
|
|
107
107
|
}
|
|
108
108
|
|
package/src/fork.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { assert, failure } from './assert.js'
|
|
|
3
3
|
import { runAsync } from './async.js'
|
|
4
4
|
import { Files } from './files.js'
|
|
5
5
|
import { $gry, $p, LogOptions, logOptions } from './log.js'
|
|
6
|
-
import { AbsolutePath,
|
|
6
|
+
import { AbsolutePath, resolveFile, requireFilename } from './paths.js'
|
|
7
7
|
import { install, Plug, PlugName } from './pipe.js'
|
|
8
8
|
import { Run, RunImpl } from './run.js'
|
|
9
9
|
|
|
@@ -220,7 +220,7 @@ if ((process.argv[1] === requireFilename(__fileurl)) && (process.send)) {
|
|
|
220
220
|
/* Contextualize this run, and go! */
|
|
221
221
|
const result = runAsync(run, taskName, async () => {
|
|
222
222
|
/* Check that we have a proper script file name */
|
|
223
|
-
assert(
|
|
223
|
+
assert(resolveFile(scriptFile), `Script file ${$p(scriptFile)} not found`)
|
|
224
224
|
const script = await import(scriptFile)
|
|
225
225
|
|
|
226
226
|
/* Figure out the constructor, in the "default" chain */
|
package/src/helpers.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbsolutePath,
|
|
3
|
+
commonPath,
|
|
4
|
+
getCurrentWorkingDirectory,
|
|
5
|
+
resolveDirectory,
|
|
6
|
+
resolveFile,
|
|
7
|
+
} from './paths.js'
|
|
8
|
+
|
|
1
9
|
import { assert } from './assert.js'
|
|
2
10
|
import { currentRun } from './async.js'
|
|
3
11
|
import { Files, FilesBuilder } from './files.js'
|
|
4
12
|
import { $p, log, LogLevelString } from './log.js'
|
|
5
|
-
import { AbsolutePath, commonPath, getCurrentWorkingDirectory, isDirectory } from './paths.js'
|
|
6
13
|
import { Pipe } from './pipe.js'
|
|
7
14
|
import { FindOptions } from './run.js'
|
|
8
15
|
import { rm } from './utils/asyncfs.js'
|
|
@@ -22,7 +29,7 @@ export async function rmrf(directory: string): Promise<void> {
|
|
|
22
29
|
assert(dir !== run.buildDir,
|
|
23
30
|
`Cowardly refusing to wipe build file directory ${$p(dir)}`)
|
|
24
31
|
|
|
25
|
-
if (!
|
|
32
|
+
if (! resolveDirectory(dir)) {
|
|
26
33
|
log.info('Directory', $p(dir), 'not found')
|
|
27
34
|
return
|
|
28
35
|
}
|
|
@@ -114,3 +121,13 @@ export function pipe(files: Files | Promise<Files>): Pipe & Promise<Files> {
|
|
|
114
121
|
assert(run, 'Unable to create pipes outside a running task')
|
|
115
122
|
return run.pipe(files)
|
|
116
123
|
}
|
|
124
|
+
|
|
125
|
+
/** Return an absolute path of the file if it exist on disk */
|
|
126
|
+
export function isFile(...paths: string[]): AbsolutePath | undefined {
|
|
127
|
+
return resolveFile(resolve(...paths))
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Return an absolute path of the file if it exist on disk */
|
|
131
|
+
export function isDirectory(...paths: string[]): AbsolutePath | undefined {
|
|
132
|
+
return resolveDirectory(resolve(...paths))
|
|
133
|
+
}
|
package/src/paths.ts
CHANGED
|
@@ -133,7 +133,7 @@ export function requireResolve(__fileurl: string, module: string): AbsolutePath
|
|
|
133
133
|
|
|
134
134
|
for (const check of checks) {
|
|
135
135
|
const resolved = fileURLToPath(new URL(check, url)) as AbsolutePath
|
|
136
|
-
if (
|
|
136
|
+
if (resolveFile(resolved)) {
|
|
137
137
|
module = check
|
|
138
138
|
break
|
|
139
139
|
}
|
|
@@ -187,7 +187,7 @@ export function commonPath(path: AbsolutePath, ...paths: string[]): AbsolutePath
|
|
|
187
187
|
* Resolves the specified path as an {@link AbsolutePath} and checks it is a
|
|
188
188
|
* _file_, returning `undefined` if it is not.
|
|
189
189
|
*/
|
|
190
|
-
export function
|
|
190
|
+
export function resolveFile(path: AbsolutePath, ...paths: string[]): AbsolutePath | undefined {
|
|
191
191
|
const file = resolveAbsolutePath(path, ...paths)
|
|
192
192
|
try {
|
|
193
193
|
const stat = statSync(file)
|
|
@@ -202,7 +202,7 @@ export function isFile(path: AbsolutePath, ...paths: string[]): AbsolutePath | u
|
|
|
202
202
|
* Resolves the specified path as an {@link AbsolutePath} and checks it is a
|
|
203
203
|
* _directory_, returning `undefined` if it is not.
|
|
204
204
|
*/
|
|
205
|
-
export function
|
|
205
|
+
export function resolveDirectory(path: AbsolutePath, ...paths: string[]): AbsolutePath | undefined {
|
|
206
206
|
const directory = resolveAbsolutePath(path, ...paths)
|
|
207
207
|
try {
|
|
208
208
|
const stat = statSync(directory)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
|
|
3
3
|
import { Plugin } from 'esbuild'
|
|
4
|
-
import { assertAbsolutePath,
|
|
4
|
+
import { assertAbsolutePath, resolveFile, resolveAbsolutePath } from '../../paths.js'
|
|
5
5
|
import { stat } from '../../utils/asyncfs.js'
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -61,7 +61,7 @@ export function fixExtensions(): Plugin {
|
|
|
61
61
|
|
|
62
62
|
/* First of all, check if the _real_ filename exists */
|
|
63
63
|
const resolved = resolveAbsolutePath(resolveDir, args.path)
|
|
64
|
-
if (
|
|
64
|
+
if (resolveFile(resolved)) return { path: args.path, external: true }
|
|
65
65
|
|
|
66
66
|
/*
|
|
67
67
|
* Thank you TypeScript 4.7!!! If the file is ".js", ".mjs" or ".cjs" we
|
|
@@ -73,7 +73,7 @@ export function fixExtensions(): Plugin {
|
|
|
73
73
|
const [ , name, ext ] = match
|
|
74
74
|
const tspath = name + ext.replace('js', 'ts')
|
|
75
75
|
const tsfile = resolveAbsolutePath(resolveDir, tspath)
|
|
76
|
-
if (
|
|
76
|
+
if (resolveFile(tsfile)) {
|
|
77
77
|
const newext = ext === '.mjs' ? mjs : ext === '.cjs' ? cjs : js
|
|
78
78
|
return { path: name + newext, external: true }
|
|
79
79
|
}
|
|
@@ -2,7 +2,7 @@ import { ESLint as RealESLint } from 'eslint'
|
|
|
2
2
|
import { assert, failure } from '../../assert.js'
|
|
3
3
|
import { Files } from '../../files.js'
|
|
4
4
|
import { $p, ERROR, NOTICE, WARN } from '../../log.js'
|
|
5
|
-
import { getCurrentWorkingDirectory,
|
|
5
|
+
import { getCurrentWorkingDirectory, resolveDirectory, resolveFile, resolveAbsolutePath } from '../../paths.js'
|
|
6
6
|
import { Plug } from '../../pipe.js'
|
|
7
7
|
import { Run } from '../../run.js'
|
|
8
8
|
import { readFile } from '../../utils/asyncfs.js'
|
|
@@ -34,11 +34,11 @@ export default class ESLint implements Plug<undefined> {
|
|
|
34
34
|
const { directory, configFile } = this._options
|
|
35
35
|
|
|
36
36
|
const cwd = directory ? run.resolve(directory) : getCurrentWorkingDirectory()
|
|
37
|
-
assert(
|
|
37
|
+
assert(resolveDirectory(cwd), `ESLint directory ${$p(cwd)} does not exist`)
|
|
38
38
|
|
|
39
39
|
const overrideConfigFile = configFile ? run.resolve(configFile) : undefined
|
|
40
40
|
if (overrideConfigFile) {
|
|
41
|
-
assert(
|
|
41
|
+
assert(resolveFile(overrideConfigFile), `ESLint configuration ${$p(overrideConfigFile)} does not exist`)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/* Create our ESLint instance */
|
package/src/plugs/exec.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { assert } from '../assert.js'
|
|
|
6
6
|
import { currentRun } from '../async.js'
|
|
7
7
|
import { Files } from '../files.js'
|
|
8
8
|
import { $p, logOptions } from '../log.js'
|
|
9
|
-
import { AbsolutePath, getCurrentWorkingDirectory,
|
|
9
|
+
import { AbsolutePath, getCurrentWorkingDirectory, resolveDirectory } from '../paths.js'
|
|
10
10
|
import { install, Plug } from '../pipe.js'
|
|
11
11
|
import { Run } from '../run.js'
|
|
12
12
|
import { parseOptions, ParseOptions } from '../utils/options.js'
|
|
@@ -156,18 +156,18 @@ async function spawnChild(
|
|
|
156
156
|
} = options
|
|
157
157
|
|
|
158
158
|
const childCwd = cwd ? run.resolve(cwd) : getCurrentWorkingDirectory()
|
|
159
|
-
assert(
|
|
159
|
+
assert(resolveDirectory(childCwd), `Current working directory ${$p(childCwd)} does not exist`)
|
|
160
160
|
|
|
161
161
|
// Figure out the PATH environment variable
|
|
162
162
|
const childPaths: AbsolutePath[] = []
|
|
163
163
|
|
|
164
164
|
// The `.../node_modules/.bin` path relative to the current working dir */
|
|
165
165
|
const baseNodePath = run.resolve('@node_modules', '.bin')
|
|
166
|
-
if (
|
|
166
|
+
if (resolveDirectory(baseNodePath)) childPaths.push(baseNodePath)
|
|
167
167
|
|
|
168
168
|
// The `.../node_bodules/.bin` path relative to the buildDir */
|
|
169
169
|
const buildNodePath = run.resolve('./node_modules', '.bin')
|
|
170
|
-
if (
|
|
170
|
+
if (resolveDirectory(buildNodePath)) childPaths.push(buildNodePath)
|
|
171
171
|
|
|
172
172
|
// Any other paths either from `process.env` or `env` (which overrides it)
|
|
173
173
|
const extraPath = env.PATH || process.env.PATH
|
package/src/plugs/tsc/runner.ts
CHANGED
|
@@ -3,7 +3,7 @@ import ts from 'typescript' // TypeScript does NOT support ESM modules
|
|
|
3
3
|
import { failure } from '../../assert.js'
|
|
4
4
|
import { Files } from '../../files.js'
|
|
5
5
|
import { $p, log } from '../../log.js'
|
|
6
|
-
import { AbsolutePath,
|
|
6
|
+
import { AbsolutePath, resolveFile } from '../../paths.js'
|
|
7
7
|
import { Plug } from '../../pipe.js'
|
|
8
8
|
import { Run } from '../../run.js'
|
|
9
9
|
import { parseOptions, ParseOptions } from '../../utils/options.js'
|
|
@@ -39,9 +39,9 @@ export default class Tsc implements Plug<Files> {
|
|
|
39
39
|
* The "tsconfig" file is either specified, or (if existing) first checked
|
|
40
40
|
* alongside the sources, otherwise checked in the current directory.
|
|
41
41
|
*/
|
|
42
|
-
const sourcesConfig =
|
|
42
|
+
const sourcesConfig = resolveFile(files.directory, 'tsconfig.json')
|
|
43
43
|
const tsconfig = this._tsconfig ? run.resolve(this._tsconfig) :
|
|
44
|
-
sourcesConfig ||
|
|
44
|
+
sourcesConfig || resolveFile(run.resolve('tsconfig.json'))
|
|
45
45
|
|
|
46
46
|
/* Root directory must always exist */
|
|
47
47
|
let rootDir: AbsolutePath
|
package/src/run.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { assert } from './assert.js'
|
|
1
|
+
import { sep } from 'node:path'
|
|
3
2
|
import { Files, FilesBuilder } from './files.js'
|
|
4
3
|
import { createReport, getLevelNumber, getLogger, Logger, LogLevelString, Report } from './log.js'
|
|
5
|
-
import { AbsolutePath, getCurrentWorkingDirectory,
|
|
4
|
+
import { AbsolutePath, getCurrentWorkingDirectory, resolveAbsolutePath } from './paths.js'
|
|
6
5
|
import { Pipe, PipeImpl } from './pipe.js'
|
|
7
6
|
import { ParseOptions, parseOptions } from './utils/options.js'
|
|
8
7
|
import { walk, WalkOptions } from './utils/walk.js'
|
|
@@ -109,20 +108,19 @@ export class RunImpl implements Run {
|
|
|
109
108
|
return createReport(title, this.taskName)
|
|
110
109
|
}
|
|
111
110
|
|
|
112
|
-
resolve(...paths: string[]): AbsolutePath {
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const relative = join(...components) // this will remove any leading slash
|
|
119
|
-
assert(! isAbsolutePath(relative), `Path "${path.substring(1)}" is absolute`)
|
|
120
|
-
return resolveAbsolutePath(this.buildDir, relative)
|
|
111
|
+
resolve(path?: string, ...paths: string[]): AbsolutePath {
|
|
112
|
+
// Paths starting with "@" are relative to the build file directory
|
|
113
|
+
if (path && path.startsWith('@')) {
|
|
114
|
+
// We can have paths like "@/../foo/bar" or "@../foo/bar"... both are ok
|
|
115
|
+
const components = path.substring(1).split(sep).filter((s) => !!s)
|
|
116
|
+
return resolveAbsolutePath(this.buildDir, ...components, ...paths)
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
|
|
119
|
+
// No path? Resolve to the CWD!
|
|
120
|
+
if (! path) return getCurrentWorkingDirectory()
|
|
124
121
|
|
|
125
|
-
|
|
122
|
+
// For all the rest, normal resolution!
|
|
123
|
+
return resolveAbsolutePath(getCurrentWorkingDirectory(), path, ...paths)
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
files(files: Files): FilesBuilder
|
package/types/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AbsolutePath } from './paths.js';
|
|
1
2
|
import { Files, FilesBuilder } from './files.js';
|
|
2
3
|
import { LogLevelString } from './log.js';
|
|
3
|
-
import { AbsolutePath } from './paths.js';
|
|
4
4
|
import { Pipe } from './pipe.js';
|
|
5
5
|
import { FindOptions } from './run.js';
|
|
6
6
|
import { ParseOptions } from './utils/options.js';
|
|
@@ -37,3 +37,7 @@ export declare function merge(args: (Files | Promise<Files>)[]): Promise<Files>
|
|
|
37
37
|
export declare function find(glob: string, ...args: ParseOptions<FindOptions>): Pipe & Promise<Files>;
|
|
38
38
|
/** Create a {@link Pipe} from a {@link Files} instance. */
|
|
39
39
|
export declare function pipe(files: Files | Promise<Files>): Pipe & Promise<Files>;
|
|
40
|
+
/** Return an absolute path of the file if it exist on disk */
|
|
41
|
+
export declare function isFile(...paths: string[]): AbsolutePath | undefined;
|
|
42
|
+
/** Return an absolute path of the file if it exist on disk */
|
|
43
|
+
export declare function isDirectory(...paths: string[]): AbsolutePath | undefined;
|
package/types/paths.d.ts
CHANGED
|
@@ -68,9 +68,9 @@ export declare function commonPath(path: AbsolutePath, ...paths: string[]): Abso
|
|
|
68
68
|
* Resolves the specified path as an {@link AbsolutePath} and checks it is a
|
|
69
69
|
* _file_, returning `undefined` if it is not.
|
|
70
70
|
*/
|
|
71
|
-
export declare function
|
|
71
|
+
export declare function resolveFile(path: AbsolutePath, ...paths: string[]): AbsolutePath | undefined;
|
|
72
72
|
/**
|
|
73
73
|
* Resolves the specified path as an {@link AbsolutePath} and checks it is a
|
|
74
74
|
* _directory_, returning `undefined` if it is not.
|
|
75
75
|
*/
|
|
76
|
-
export declare function
|
|
76
|
+
export declare function resolveDirectory(path: AbsolutePath, ...paths: string[]): AbsolutePath | undefined;
|
package/types/run.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export declare class RunImpl implements Run {
|
|
|
80
80
|
/** Set the logging level within this {@link Run} */
|
|
81
81
|
setLogLevel(level: LogLevelString): void;
|
|
82
82
|
report(title: string): Report;
|
|
83
|
-
resolve(...paths: string[]): AbsolutePath;
|
|
83
|
+
resolve(path?: string, ...paths: string[]): AbsolutePath;
|
|
84
84
|
files(files: Files): FilesBuilder;
|
|
85
85
|
files(...paths: string[]): FilesBuilder;
|
|
86
86
|
find(glob: string, ...args: ParseOptions<FindOptions>): Pipe & Promise<Files>;
|