@plugjs/plug 0.0.12 → 0.0.15
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/{types → dist}/assert.d.ts +0 -0
- package/dist/async.cjs +20 -19
- package/dist/async.cjs.map +1 -1
- package/dist/async.d.ts +20 -0
- package/dist/async.mjs +18 -17
- package/dist/async.mjs.map +1 -1
- package/dist/build.cjs +144 -110
- package/dist/build.cjs.map +2 -2
- package/dist/build.d.ts +12 -0
- package/dist/build.mjs +146 -112
- package/dist/build.mjs.map +2 -2
- package/dist/files.cjs +2 -16
- package/dist/files.cjs.map +1 -1
- package/{types → dist}/files.d.ts +3 -10
- package/dist/files.mjs +3 -17
- package/dist/files.mjs.map +1 -1
- package/dist/fork.cjs +28 -40
- package/dist/fork.cjs.map +1 -1
- package/dist/fork.d.ts +36 -0
- package/dist/fork.mjs +29 -40
- package/dist/fork.mjs.map +1 -1
- package/dist/helpers.cjs +61 -63
- package/dist/helpers.cjs.map +2 -2
- package/dist/helpers.d.ts +21 -0
- package/dist/helpers.mjs +61 -64
- package/dist/helpers.mjs.map +2 -2
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/log/colors.cjs +3 -1
- package/dist/log/colors.cjs.map +1 -1
- package/{types → dist}/log/colors.d.ts +2 -2
- package/dist/log/colors.mjs +3 -1
- package/dist/log/colors.mjs.map +1 -1
- package/{types → dist}/log/emit.d.ts +1 -1
- package/{types → dist}/log/levels.d.ts +0 -0
- package/dist/log/logger.cjs +4 -0
- package/dist/log/logger.cjs.map +1 -1
- package/{types → dist}/log/logger.d.ts +4 -1
- package/dist/log/logger.mjs +4 -0
- package/dist/log/logger.mjs.map +1 -1
- package/{types → dist}/log/options.d.ts +1 -1
- package/dist/log/report.cjs +4 -13
- package/dist/log/report.cjs.map +1 -1
- package/{types → dist}/log/report.d.ts +36 -4
- package/dist/log/report.mjs +3 -12
- package/dist/log/report.mjs.map +1 -1
- package/{types → dist}/log/spinner.d.ts +0 -0
- package/dist/log.cjs +1 -1
- package/dist/log.cjs.map +1 -1
- package/{types → dist}/log.d.ts +6 -6
- package/dist/log.mjs +2 -2
- package/dist/log.mjs.map +1 -1
- package/{types → dist}/paths.d.ts +0 -0
- package/dist/pipe.cjs +41 -34
- package/dist/pipe.cjs.map +1 -1
- package/dist/pipe.d.ts +182 -0
- package/dist/pipe.mjs +38 -32
- package/dist/pipe.mjs.map +1 -1
- package/dist/plugs/copy.cjs +15 -25
- package/dist/plugs/copy.cjs.map +2 -2
- package/dist/plugs/copy.d.ts +28 -0
- package/dist/plugs/copy.mjs +15 -17
- package/dist/plugs/copy.mjs.map +2 -2
- package/{types → dist}/plugs/coverage/analysis.d.ts +2 -2
- package/dist/plugs/coverage/report.cjs +4 -2
- package/dist/plugs/coverage/report.cjs.map +1 -1
- package/{types → dist}/plugs/coverage/report.d.ts +3 -3
- package/dist/plugs/coverage/report.mjs +4 -2
- package/dist/plugs/coverage/report.mjs.map +1 -1
- package/dist/plugs/coverage.cjs +23 -27
- package/dist/plugs/coverage.cjs.map +1 -1
- package/dist/plugs/coverage.d.ts +49 -0
- package/dist/plugs/coverage.mjs +24 -20
- package/dist/plugs/coverage.mjs.map +1 -1
- package/dist/plugs/debug.cjs +8 -37
- package/dist/plugs/debug.cjs.map +1 -1
- package/dist/plugs/debug.d.ts +7 -0
- package/dist/plugs/debug.mjs +24 -20
- package/dist/plugs/debug.mjs.map +1 -1
- package/{types → dist}/plugs/esbuild/bundle-locals.d.ts +0 -0
- package/{types → dist}/plugs/esbuild/fix-extensions.d.ts +0 -0
- package/dist/plugs/esbuild/fix-extensions.mjs +1 -1
- package/dist/plugs/esbuild/fix-extensions.mjs.map +1 -1
- package/dist/plugs/esbuild.cjs +14 -25
- package/dist/plugs/esbuild.cjs.map +1 -1
- package/dist/plugs/esbuild.d.ts +18 -0
- package/dist/plugs/esbuild.mjs +14 -17
- package/dist/plugs/esbuild.mjs.map +1 -1
- package/dist/plugs/eslint/runner.cjs +5 -6
- package/dist/plugs/eslint/runner.cjs.map +1 -1
- package/dist/plugs/eslint/runner.d.ts +8 -0
- package/dist/plugs/eslint/runner.mjs +6 -7
- package/dist/plugs/eslint/runner.mjs.map +1 -1
- package/dist/{task.cjs → plugs/eslint.cjs} +7 -24
- package/dist/plugs/eslint.cjs.map +6 -0
- package/dist/plugs/eslint.d.ts +34 -0
- package/dist/plugs/eslint.mjs +5 -0
- package/dist/plugs/eslint.mjs.map +6 -0
- package/dist/plugs/exec.cjs +20 -24
- package/dist/plugs/exec.cjs.map +1 -1
- package/dist/plugs/exec.d.ts +90 -0
- package/dist/plugs/exec.mjs +20 -23
- package/dist/plugs/exec.mjs.map +1 -1
- package/dist/plugs/filter.cjs +9 -19
- package/dist/plugs/filter.cjs.map +1 -1
- package/dist/plugs/filter.d.ts +29 -0
- package/dist/plugs/filter.mjs +10 -12
- package/dist/plugs/filter.mjs.map +1 -1
- package/dist/plugs/mocha/reporter.cjs +19 -6
- package/dist/plugs/mocha/reporter.cjs.map +1 -1
- package/{types → dist}/plugs/mocha/reporter.d.ts +0 -2
- package/dist/plugs/mocha/reporter.mjs +18 -4
- package/dist/plugs/mocha/reporter.mjs.map +1 -1
- package/dist/plugs/mocha/runner.cjs +4 -5
- package/dist/plugs/mocha/runner.cjs.map +1 -1
- package/dist/plugs/mocha/runner.d.ts +8 -0
- package/dist/plugs/mocha/runner.mjs +5 -6
- package/dist/plugs/mocha/runner.mjs.map +1 -1
- package/dist/plugs/mocha.cjs +22 -0
- package/dist/plugs/mocha.cjs.map +6 -0
- package/{types/plugs/mocha/runner.d.ts → dist/plugs/mocha.d.ts} +9 -8
- package/dist/plugs/mocha.mjs +5 -0
- package/dist/plugs/mocha.mjs.map +6 -0
- package/dist/plugs/rmf.cjs +4 -32
- package/dist/plugs/rmf.cjs.map +1 -1
- package/dist/plugs/rmf.d.ts +11 -0
- package/dist/plugs/rmf.mjs +25 -20
- package/dist/plugs/rmf.mjs.map +1 -1
- package/{types → dist}/plugs/tsc/compiler.d.ts +1 -1
- package/{types → dist}/plugs/tsc/options.d.ts +1 -1
- package/{types → dist}/plugs/tsc/report.d.ts +2 -2
- package/dist/plugs/tsc/runner.cjs +12 -11
- package/dist/plugs/tsc/runner.cjs.map +1 -1
- package/dist/plugs/tsc/runner.d.ts +8 -0
- package/dist/plugs/tsc/runner.mjs +12 -11
- package/dist/plugs/tsc/runner.mjs.map +1 -1
- package/dist/plugs/tsc.cjs +7 -0
- package/dist/plugs/tsc.cjs.map +6 -0
- package/dist/plugs/tsc.d.ts +36 -0
- package/dist/plugs/tsc.mjs +15 -0
- package/dist/plugs/tsc.mjs.map +6 -0
- package/dist/plugs.cjs +3 -5
- package/dist/plugs.cjs.map +1 -1
- package/dist/plugs.d.ts +10 -0
- package/dist/plugs.mjs +3 -5
- package/dist/plugs.mjs.map +1 -1
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +6 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +6 -0
- package/{types → dist}/utils/asyncfs.d.ts +0 -0
- package/dist/utils/caller.cjs +8 -11
- package/dist/utils/caller.cjs.map +2 -2
- package/dist/utils/caller.d.ts +2 -0
- package/dist/utils/caller.mjs +8 -11
- package/dist/utils/caller.mjs.map +2 -2
- package/{types → dist}/utils/match.d.ts +0 -0
- package/dist/utils/options.cjs +4 -6
- package/dist/utils/options.cjs.map +1 -1
- package/dist/utils/options.d.ts +16 -0
- package/dist/utils/options.mjs +4 -6
- package/dist/utils/options.mjs.map +1 -1
- package/{types → dist}/utils/walk.d.ts +2 -2
- package/extra/cli.mjs +31 -20
- package/extra/ts-loader.mjs +6 -5
- package/package.json +10 -10
- package/src/async.ts +27 -19
- package/src/files.ts +6 -30
- package/src/fork.ts +35 -76
- package/src/helpers.ts +89 -101
- package/src/index.ts +10 -15
- package/src/log/colors.ts +4 -3
- package/src/log/emit.ts +4 -4
- package/src/log/logger.ts +12 -4
- package/src/log/options.ts +1 -1
- package/src/log/report.ts +10 -24
- package/src/log/spinner.ts +3 -3
- package/src/log.ts +9 -9
- package/src/paths.ts +1 -1
- package/src/pipe.ts +191 -178
- package/src/plugs/copy.ts +40 -31
- package/src/plugs/coverage/analysis.ts +4 -4
- package/src/plugs/coverage/report.ts +9 -6
- package/src/plugs/coverage.ts +68 -55
- package/src/plugs/debug.ts +22 -27
- package/src/plugs/esbuild/fix-extensions.ts +2 -2
- package/src/plugs/esbuild.ts +42 -46
- package/src/plugs/eslint/runner.ts +16 -31
- package/src/plugs/eslint.ts +42 -0
- package/src/plugs/exec.ts +93 -82
- package/src/plugs/filter.ts +42 -27
- package/src/plugs/mocha/reporter.ts +19 -5
- package/src/plugs/mocha/runner.ts +12 -38
- package/src/plugs/mocha.ts +41 -0
- package/src/plugs/rmf.ts +21 -25
- package/src/plugs/tsc/compiler.ts +1 -1
- package/src/plugs/tsc/options.ts +2 -2
- package/src/plugs/tsc/report.ts +2 -2
- package/src/plugs/tsc/runner.ts +24 -30
- package/src/plugs/tsc.ts +45 -0
- package/src/plugs.ts +10 -25
- package/src/types.ts +123 -0
- package/src/utils/caller.ts +11 -22
- package/src/utils/options.ts +49 -17
- package/src/utils/walk.ts +4 -4
- package/dist/run.cjs +0 -90
- package/dist/run.cjs.map +0 -6
- package/dist/run.mjs +0 -65
- package/dist/run.mjs.map +0 -6
- package/dist/task.cjs.map +0 -6
- package/dist/task.mjs +0 -14
- package/dist/task.mjs.map +0 -6
- package/src/run.ts +0 -159
- package/src/task.ts +0 -26
- package/types/async.d.ts +0 -20
- package/types/build.d.ts +0 -56
- package/types/fork.d.ts +0 -57
- package/types/helpers.d.ts +0 -43
- package/types/index.d.ts +0 -14
- package/types/pipe.d.ts +0 -152
- package/types/plugs/copy.d.ts +0 -27
- package/types/plugs/coverage.d.ts +0 -46
- package/types/plugs/debug.d.ts +0 -14
- package/types/plugs/esbuild.d.ts +0 -23
- package/types/plugs/eslint/runner.d.ts +0 -22
- package/types/plugs/exec.d.ts +0 -90
- package/types/plugs/filter.d.ts +0 -23
- package/types/plugs/rmf.d.ts +0 -15
- package/types/plugs/tsc/runner.d.ts +0 -13
- package/types/plugs.d.ts +0 -17
- package/types/run.d.ts +0 -89
- package/types/task.d.ts +0 -15
- package/types/utils/caller.d.ts +0 -7
- package/types/utils/options.d.ts +0 -15
package/dist/plugs/esbuild.mjs
CHANGED
|
@@ -2,23 +2,24 @@
|
|
|
2
2
|
import { build } from "esbuild";
|
|
3
3
|
import { basename } from "node:path";
|
|
4
4
|
import { assert } from "../assert.mjs";
|
|
5
|
+
import { Files } from "../files.mjs";
|
|
5
6
|
import { $p, ERROR, WARN } from "../log.mjs";
|
|
6
7
|
import { getAbsoluteParent, resolveAbsolutePath } from "../paths.mjs";
|
|
7
8
|
import { install } from "../pipe.mjs";
|
|
8
9
|
import { readFile } from "../utils/asyncfs.mjs";
|
|
9
10
|
export * from "./esbuild/bundle-locals.mjs";
|
|
10
11
|
export * from "./esbuild/fix-extensions.mjs";
|
|
11
|
-
|
|
12
|
+
install("esbuild", class ESBuild {
|
|
12
13
|
constructor(_options) {
|
|
13
14
|
this._options = _options;
|
|
14
15
|
}
|
|
15
|
-
async pipe(files,
|
|
16
|
+
async pipe(files, context) {
|
|
16
17
|
const entryPoints = [...files];
|
|
17
18
|
const absWorkingDir = files.directory;
|
|
18
19
|
const options = {
|
|
19
20
|
platform: "node",
|
|
20
21
|
target: `node${process.versions["node"].split(".")[0]}`,
|
|
21
|
-
format: this._options.format || await _moduleFormat(files.directory,
|
|
22
|
+
format: this._options.format || await _moduleFormat(files.directory, context.log),
|
|
22
23
|
outbase: absWorkingDir,
|
|
23
24
|
...this._options,
|
|
24
25
|
absWorkingDir,
|
|
@@ -29,24 +30,24 @@ var ESBuild = class {
|
|
|
29
30
|
assert(!(options.outdir && options.outfile), 'Options "outfile" and "outdir" can not coexist');
|
|
30
31
|
let builder;
|
|
31
32
|
if (options.bundle && options.outfile && entryPoints.length === 1) {
|
|
32
|
-
builder =
|
|
33
|
+
builder = Files.builder(absWorkingDir);
|
|
33
34
|
const outputFile = resolveAbsolutePath(absWorkingDir, options.outfile);
|
|
34
35
|
const entryPoint = resolveAbsolutePath(absWorkingDir, entryPoints[0]);
|
|
35
36
|
options.outfile = outputFile;
|
|
36
|
-
|
|
37
|
+
context.log.debug("Bundling", $p(entryPoint), "into", $p(outputFile));
|
|
37
38
|
} else {
|
|
38
39
|
assert(options.outdir, 'Option "outdir" must be specified');
|
|
39
|
-
builder =
|
|
40
|
+
builder = Files.builder(context.resolve(options.outdir));
|
|
40
41
|
options.outdir = builder.directory;
|
|
41
42
|
const message = options.bundle ? "Bundling" : "Transpiling";
|
|
42
|
-
|
|
43
|
+
context.log.debug(message, entryPoints.length, "files to", $p(builder.directory));
|
|
43
44
|
}
|
|
44
|
-
const report =
|
|
45
|
-
|
|
45
|
+
const report = context.log.report("ESBuild Report");
|
|
46
|
+
context.log.trace("Running ESBuild", options);
|
|
46
47
|
let esbuild;
|
|
47
48
|
try {
|
|
48
49
|
esbuild = await build({ ...options, metafile: true });
|
|
49
|
-
|
|
50
|
+
context.log.trace("ESBuild Results", esbuild);
|
|
50
51
|
report.add(...esbuild.warnings.map((m) => convertMessage(WARN, m, absWorkingDir)));
|
|
51
52
|
report.add(...esbuild.errors.map((m) => convertMessage(ERROR, m, absWorkingDir)));
|
|
52
53
|
} catch (error) {
|
|
@@ -60,13 +61,13 @@ var ESBuild = class {
|
|
|
60
61
|
report.done();
|
|
61
62
|
assert(esbuild, "ESBuild did not produce any result");
|
|
62
63
|
for (const file in esbuild.metafile.outputs) {
|
|
63
|
-
builder.
|
|
64
|
+
builder.add(resolveAbsolutePath(absWorkingDir, file));
|
|
64
65
|
}
|
|
65
66
|
const result = builder.build();
|
|
66
|
-
|
|
67
|
+
context.log.info("ESBuild produced", result.length, "files into", $p(result.directory));
|
|
67
68
|
return result;
|
|
68
69
|
}
|
|
69
|
-
};
|
|
70
|
+
});
|
|
70
71
|
function convertMessage(level, message, directory) {
|
|
71
72
|
const record = { level, message: message.text };
|
|
72
73
|
record.tags = [message.id, message.pluginName].filter((tag) => !!tag);
|
|
@@ -77,7 +78,6 @@ function convertMessage(level, message, directory) {
|
|
|
77
78
|
}
|
|
78
79
|
return record;
|
|
79
80
|
}
|
|
80
|
-
install("esbuild", ESBuild);
|
|
81
81
|
var _moduleFormatCache = /* @__PURE__ */ new Map();
|
|
82
82
|
async function _moduleFormat(directory, log) {
|
|
83
83
|
const type = _moduleFormatCache.get(directory);
|
|
@@ -106,7 +106,4 @@ async function _moduleFormat(directory, log) {
|
|
|
106
106
|
return type2;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
export {
|
|
110
|
-
ESBuild
|
|
111
|
-
};
|
|
112
109
|
//# sourceMappingURL=esbuild.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/plugs/esbuild.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,aAAiF;AAC1F,SAAS,gBAAgB;AACzB,SAAS,cAAc;
|
|
4
|
+
"mappings": ";AAAA,SAAS,aAAiF;AAC1F,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,aAA2B;AACpC,SAAS,IAAI,OAA0C,YAAY;AACnE,SAAuB,mBAAmB,2BAA2B;AACrE,SAAS,eAA8C;AACvD,SAAS,gBAAgB;AAIzB,cAAc;AACd,cAAc;AAqBd,QAAQ,WAAW,MAAM,QAA+B;AAAA,EAEtD,YAA6B,UAA0B;AAA1B;AAAA,EAA2B;AAAA,EAExD,MAAM,KAAK,OAAc,SAAkC;AACzD,UAAM,cAAc,CAAE,GAAG,KAAM;AAC/B,UAAM,gBAAgB,MAAM;AAE5B,UAAM,UAAwB;AAAA,MAE5B,UAAU;AAAA,MACV,QAAQ,OAAO,QAAQ,SAAS,QAAQ,MAA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AK,SAAS,WAAW,QAAQ;AAC9C,QAAI,MAAM,SAAS,iCAAiC,KAAK,UAAUA,QAAO;AAC1E,uBAAmB,IAAI,WAAWA,KAAI;AACtC,WAAOA;AAAA,EACT,SAAS,OAAP;AAEA,QAAK,MAAM,SAAS,YAAc,MAAM,SAAS;AAAW,YAAM;AAAA,EACpE;AASA,QAAM,OAAO,SAAS,SAAS;AAC/B,QAAM,SAAS,kBAAkB,SAAS;AAE1C,MAAK,SAAS,kBAAoB,WAAW,WAAY;AACvD,uBAAmB,IAAI,WAAW,KAAK;AACvC,WAAO;AAAA,EACT,OAAO;AAEL,UAAMA,QAAO,MAAM,cAAc,QAAQ,GAAG;AAC5C,uBAAmB,IAAI,WAAWA,KAAI;AACtC,WAAOA;AAAA,EACT;AACF;",
|
|
5
5
|
"names": ["type"]
|
|
6
6
|
}
|
|
@@ -33,11 +33,11 @@ var ESLint = class {
|
|
|
33
33
|
constructor(arg = {}) {
|
|
34
34
|
this._options = typeof arg === "string" ? { configFile: arg } : arg;
|
|
35
35
|
}
|
|
36
|
-
async pipe(files,
|
|
36
|
+
async pipe(files, context) {
|
|
37
37
|
const { directory, configFile } = this._options;
|
|
38
|
-
const cwd = directory ?
|
|
38
|
+
const cwd = directory ? context.resolve(directory) : (0, import_paths.getCurrentWorkingDirectory)();
|
|
39
39
|
(0, import_assert.assert)((0, import_paths.resolveDirectory)(cwd), `ESLint directory ${(0, import_log.$p)(cwd)} does not exist`);
|
|
40
|
-
const overrideConfigFile = configFile ?
|
|
40
|
+
const overrideConfigFile = configFile ? context.resolve(configFile) : void 0;
|
|
41
41
|
if (overrideConfigFile) {
|
|
42
42
|
(0, import_assert.assert)((0, import_paths.resolveFile)(overrideConfigFile), `ESLint configuration ${(0, import_log.$p)(overrideConfigFile)} does not exist`);
|
|
43
43
|
}
|
|
@@ -50,7 +50,7 @@ var ESLint = class {
|
|
|
50
50
|
const settlements = await Promise.allSettled(promises);
|
|
51
51
|
const summary = settlements.reduce((summary2, settlement, i) => {
|
|
52
52
|
if (settlement.status === "rejected") {
|
|
53
|
-
|
|
53
|
+
context.log.error("Error linting", (0, import_log.$p)(paths[i]), settlement.reason);
|
|
54
54
|
summary2.failures++;
|
|
55
55
|
return summary2;
|
|
56
56
|
}
|
|
@@ -63,7 +63,7 @@ var ESLint = class {
|
|
|
63
63
|
const { results, failures } = summary;
|
|
64
64
|
if (failures)
|
|
65
65
|
throw (0, import_assert.failure)();
|
|
66
|
-
const report =
|
|
66
|
+
const report = context.log.report("ESLint Report");
|
|
67
67
|
for (const result of results) {
|
|
68
68
|
const { filePath, source, messages } = result;
|
|
69
69
|
const file = (0, import_paths.resolveAbsolutePath)((0, import_paths.getCurrentWorkingDirectory)(), filePath);
|
|
@@ -83,7 +83,6 @@ var ESLint = class {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
report.done(this._options.showSources);
|
|
86
|
-
return void 0;
|
|
87
86
|
}
|
|
88
87
|
};
|
|
89
88
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugs/eslint/runner.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAqC;AACrC,oBAAgC;AAEhC,iBAAwC;AACxC,mBAA+F;
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAqC;AACrC,oBAAgC;AAEhC,iBAAwC;AACxC,mBAA+F;AAE/F,qBAAyB;AAIzB,IAAqB,SAArB,MAAkD;AAAA,EAC/B;AAAA,EAGjB,YAAY,MAA8B,CAAC,GAAG;AAC5C,SAAK,WAAW,OAAO,QAAQ,WAAW,EAAE,YAAY,IAAI,IAAI;AAAA,EAClE;AAAA,EAEA,MAAM,KAAK,OAAc,SAAiC;AACxD,UAAM,EAAE,WAAW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;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,UACR;AAAA,UACA;AAAA,UACA,UAAU;AAAA,UACV,YAAY,SAAS;AAAA,QACvB,IAAI;AAGJ,cAAM,QAAQ,aAAa,IAAI,oBAAS,aAAa,IAAI,kBAAO;AAGhE,cAAM,SAAS,YAAY,OAAO,YAAY,SAAS,UAAU,OAAO,KAAK;AAG7E,eAAO,IAAI,EAAE,OAAO,SAAS,MAAM,MAAM,QAAQ,QAAQ,MAAM,OAAO,CAAC;AAAA,MACzE;AAAA,IACF;AAGA,WAAO,KAAK,KAAK,SAAS,WAAW;AAAA,EACvC;AACF;",
|
|
5
5
|
"names": ["RealESLint", "summary"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Files } from '../../files';
|
|
2
|
+
import { PipeParameters, Plug, Context } from '../../pipe';
|
|
3
|
+
/** Runner implementation for the `ESLint` plug. */
|
|
4
|
+
export default class ESLint implements Plug<void> {
|
|
5
|
+
private readonly _options;
|
|
6
|
+
constructor(...arg: PipeParameters<'eslint'>);
|
|
7
|
+
pipe(files: Files, context: Context): Promise<void>;
|
|
8
|
+
}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import { ESLint as RealESLint } from "eslint";
|
|
3
3
|
import { assert, failure } from "../../assert.mjs";
|
|
4
4
|
import { $p, ERROR, NOTICE, WARN } from "../../log.mjs";
|
|
5
|
-
import { getCurrentWorkingDirectory, resolveDirectory, resolveFile
|
|
5
|
+
import { getCurrentWorkingDirectory, resolveAbsolutePath, resolveDirectory, resolveFile } from "../../paths.mjs";
|
|
6
6
|
import { readFile } from "../../utils/asyncfs.mjs";
|
|
7
7
|
var ESLint = class {
|
|
8
8
|
_options;
|
|
9
9
|
constructor(arg = {}) {
|
|
10
10
|
this._options = typeof arg === "string" ? { configFile: arg } : arg;
|
|
11
11
|
}
|
|
12
|
-
async pipe(files,
|
|
12
|
+
async pipe(files, context) {
|
|
13
13
|
const { directory, configFile } = this._options;
|
|
14
|
-
const cwd = directory ?
|
|
14
|
+
const cwd = directory ? context.resolve(directory) : getCurrentWorkingDirectory();
|
|
15
15
|
assert(resolveDirectory(cwd), `ESLint directory ${$p(cwd)} does not exist`);
|
|
16
|
-
const overrideConfigFile = configFile ?
|
|
16
|
+
const overrideConfigFile = configFile ? context.resolve(configFile) : void 0;
|
|
17
17
|
if (overrideConfigFile) {
|
|
18
18
|
assert(resolveFile(overrideConfigFile), `ESLint configuration ${$p(overrideConfigFile)} does not exist`);
|
|
19
19
|
}
|
|
@@ -26,7 +26,7 @@ var ESLint = class {
|
|
|
26
26
|
const settlements = await Promise.allSettled(promises);
|
|
27
27
|
const summary = settlements.reduce((summary2, settlement, i) => {
|
|
28
28
|
if (settlement.status === "rejected") {
|
|
29
|
-
|
|
29
|
+
context.log.error("Error linting", $p(paths[i]), settlement.reason);
|
|
30
30
|
summary2.failures++;
|
|
31
31
|
return summary2;
|
|
32
32
|
}
|
|
@@ -39,7 +39,7 @@ var ESLint = class {
|
|
|
39
39
|
const { results, failures } = summary;
|
|
40
40
|
if (failures)
|
|
41
41
|
throw failure();
|
|
42
|
-
const report =
|
|
42
|
+
const report = context.log.report("ESLint Report");
|
|
43
43
|
for (const result of results) {
|
|
44
44
|
const { filePath, source, messages } = result;
|
|
45
45
|
const file = resolveAbsolutePath(getCurrentWorkingDirectory(), filePath);
|
|
@@ -59,7 +59,6 @@ var ESLint = class {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
report.done(this._options.showSources);
|
|
62
|
-
return void 0;
|
|
63
62
|
}
|
|
64
63
|
};
|
|
65
64
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugs/eslint/runner.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,UAAU,kBAAkB;AACrC,SAAS,QAAQ,eAAe;AAEhC,SAAS,IAAI,OAAO,QAAQ,YAAY;AACxC,SAAS,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Q,KAAK,GAAG,WAAW,KAAK;AACxC,aAAOA;AAAA,IACT,GAAG;AAAA,MACD,SAAS,CAAC;AAAA,MACV,UAAU;AAAA,IACZ,CAAC;AAGD,UAAM,EAAE,SAAS,SAAS,IAAI;AAC9B,QAAI;AAAU,YAAM,QAAQ;AAG5B,UAAM,SAAS,QAAQ,IAAI,OAAO,eAAe;AAGjD,eAAW,UAAU,SAAS;AAC5B,YAAM,EAAE,UAAU,QAAQ,SAAS,IAAI;AACvC,YAAM,OAAO,oBAAoB,2BAA2B,GAAG,QAAQ;AAEvE,iBAAW,UAAU,UAAU;AAC7B,cAAM;AAAA,UACJ;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,UACR;AAAA,UACA;AAAA,UACA,UAAU;AAAA,UACV,YAAY,SAAS;AAAA,QACvB,IAAI;AAGJ,cAAM,QAAQ,aAAa,IAAI,SAAS,aAAa,IAAI,OAAO;AAGhE,cAAM,SAAS,YAAY,OAAO,YAAY,SAAS,UAAU,OAAO,KAAK;AAG7E,eAAO,IAAI,EAAE,OAAO,SAAS,MAAM,MAAM,QAAQ,QAAQ,MAAM,OAAO,CAAC;AAAA,MACzE;AAAA,IACF;AAGA,WAAO,KAAK,KAAK,SAAS,WAAW;AAAA,EACvC;AACF;",
|
|
5
5
|
"names": ["summary"]
|
|
6
6
|
}
|
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -17,23 +13,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
13
|
};
|
|
18
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
15
|
|
|
20
|
-
//
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
constructor(context, _definition) {
|
|
28
|
-
this.context = context;
|
|
29
|
-
this._definition = _definition;
|
|
30
|
-
}
|
|
31
|
-
async call(self, run) {
|
|
32
|
-
return await this._definition.call(self, self, run) || void 0;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
TaskImpl
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=task.cjs.map
|
|
16
|
+
// plugs/eslint.ts
|
|
17
|
+
var eslint_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(eslint_exports);
|
|
19
|
+
var import_paths = require("../paths.cjs");
|
|
20
|
+
var import_pipe = require("../pipe.cjs");
|
|
21
|
+
(0, import_pipe.installForking)("eslint", (0, import_paths.requireResolve)(__filename, "./eslint/runner"));
|
|
22
|
+
//# sourceMappingURL=eslint.cjs.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface ESLintOptions {
|
|
2
|
+
/** ESLint's own _current working directory_, where config files are. */
|
|
3
|
+
directory?: string;
|
|
4
|
+
/** Show sources in report? */
|
|
5
|
+
showSources?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* ESLint's _override_ configuration file: configurations specified in this
|
|
8
|
+
* file will override any other configuration specified elsewhere.
|
|
9
|
+
*/
|
|
10
|
+
configFile?: string;
|
|
11
|
+
}
|
|
12
|
+
declare module '../pipe' {
|
|
13
|
+
interface Pipe {
|
|
14
|
+
/**
|
|
15
|
+
* Run {@link https://eslint.org/ _ESlint_} over the input source files,
|
|
16
|
+
* using the configuration from the local `.eslintrc.*` file.
|
|
17
|
+
*/
|
|
18
|
+
eslint(): Promise<undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Run {@link https://eslint.org/ _ESlint_} over the input source files,
|
|
21
|
+
* using the configuration from the specified `configFile` (this wil
|
|
22
|
+
* override any `.eslintrc.*` file).
|
|
23
|
+
*
|
|
24
|
+
* @param configFile The configuration file to use
|
|
25
|
+
*/
|
|
26
|
+
eslint(configFile: string): Promise<undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Run {@link https://eslint.org/ _ESlint_} over the input source files..
|
|
29
|
+
*
|
|
30
|
+
* @param options {@link ESLintOptions | Options} to pass to _ESLint_
|
|
31
|
+
*/
|
|
32
|
+
eslint(options: ESLintOptions): Promise<undefined>;
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/plugs/exec.cjs
CHANGED
|
@@ -26,7 +26,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
26
26
|
// plugs/exec.ts
|
|
27
27
|
var exec_exports = {};
|
|
28
28
|
__export(exec_exports, {
|
|
29
|
-
Exec: () => Exec,
|
|
30
29
|
exec: () => exec
|
|
31
30
|
});
|
|
32
31
|
module.exports = __toCommonJS(exec_exports);
|
|
@@ -34,60 +33,58 @@ var import_node_path = __toESM(require("node:path"));
|
|
|
34
33
|
var import_node_readline = __toESM(require("node:readline"));
|
|
35
34
|
var import_node_child_process = require("node:child_process");
|
|
36
35
|
var import_assert = require("../assert.cjs");
|
|
37
|
-
var import_async = require("../async.cjs");
|
|
38
36
|
var import_log = require("../log.cjs");
|
|
39
37
|
var import_paths = require("../paths.cjs");
|
|
40
38
|
var import_pipe = require("../pipe.cjs");
|
|
41
39
|
var import_options = require("../utils/options.cjs");
|
|
42
|
-
var
|
|
40
|
+
var import_async = require("../async.cjs");
|
|
41
|
+
(0, import_pipe.install)("exec", class Exec {
|
|
43
42
|
_cmd;
|
|
44
43
|
_args;
|
|
45
44
|
_options;
|
|
46
|
-
constructor(
|
|
45
|
+
constructor(...args) {
|
|
47
46
|
const { params, options } = (0, import_options.parseOptions)(args, {});
|
|
48
|
-
|
|
49
|
-
this.
|
|
47
|
+
const [_cmd, ..._args] = params;
|
|
48
|
+
this._cmd = _cmd;
|
|
49
|
+
this._args = _args;
|
|
50
50
|
this._options = options;
|
|
51
51
|
}
|
|
52
|
-
async pipe(files,
|
|
52
|
+
async pipe(files, context) {
|
|
53
53
|
const { relativePaths = true, ...options } = this._options;
|
|
54
54
|
if (!options.cwd)
|
|
55
55
|
options.cwd = files.directory;
|
|
56
56
|
const params = [...relativePaths ? files : files.absolutePaths()];
|
|
57
57
|
if (options.shell)
|
|
58
58
|
params.forEach((s, i, a) => a[i] = JSON.stringify(s));
|
|
59
|
-
await spawnChild(this._cmd, [...this._args, ...params], options,
|
|
59
|
+
await spawnChild(this._cmd, [...this._args, ...params], options, context);
|
|
60
60
|
return files;
|
|
61
61
|
}
|
|
62
|
-
};
|
|
62
|
+
});
|
|
63
63
|
function exec(cmd, ...args) {
|
|
64
|
-
const
|
|
65
|
-
(
|
|
66
|
-
const { params, options } = (0, import_options.parseOptions)(args, {});
|
|
67
|
-
return spawnChild(cmd, params, options, run);
|
|
64
|
+
const { params, options } = (0, import_options.parseOptions)(args);
|
|
65
|
+
return spawnChild(cmd, params, options, (0, import_async.requireContext)());
|
|
68
66
|
}
|
|
69
|
-
(
|
|
70
|
-
async function spawnChild(cmd, args, options = {}, run) {
|
|
67
|
+
async function spawnChild(cmd, args, options = {}, context) {
|
|
71
68
|
const {
|
|
72
69
|
env = {},
|
|
73
70
|
shell = false,
|
|
74
71
|
cwd = void 0,
|
|
75
72
|
...extraOptions
|
|
76
73
|
} = options;
|
|
77
|
-
const childCwd = cwd ?
|
|
74
|
+
const childCwd = cwd ? context.resolve(cwd) : (0, import_paths.getCurrentWorkingDirectory)();
|
|
78
75
|
(0, import_assert.assert)((0, import_paths.resolveDirectory)(childCwd), `Current working directory ${(0, import_log.$p)(childCwd)} does not exist`);
|
|
79
76
|
const childPaths = [];
|
|
80
|
-
const baseNodePath =
|
|
77
|
+
const baseNodePath = context.resolve("@node_modules", ".bin");
|
|
81
78
|
if ((0, import_paths.resolveDirectory)(baseNodePath))
|
|
82
79
|
childPaths.push(baseNodePath);
|
|
83
|
-
const buildNodePath =
|
|
80
|
+
const buildNodePath = context.resolve("./node_modules", ".bin");
|
|
84
81
|
if ((0, import_paths.resolveDirectory)(buildNodePath))
|
|
85
82
|
childPaths.push(buildNodePath);
|
|
86
83
|
const extraPath = env.PATH || process.env.PATH;
|
|
87
84
|
if (extraPath)
|
|
88
85
|
childPaths.push(extraPath);
|
|
89
86
|
const PATH = childPaths.join(import_node_path.default.delimiter);
|
|
90
|
-
const __LOG_OPTIONS = JSON.stringify(import_log.logOptions.fork(
|
|
87
|
+
const __LOG_OPTIONS = JSON.stringify(import_log.logOptions.fork(context.taskName));
|
|
91
88
|
const childEnv = { ...process.env, ...env, PATH, __LOG_OPTIONS };
|
|
92
89
|
const childOptions = {
|
|
93
90
|
...extraOptions,
|
|
@@ -96,16 +93,16 @@ async function spawnChild(cmd, args, options = {}, run) {
|
|
|
96
93
|
env: childEnv,
|
|
97
94
|
shell
|
|
98
95
|
};
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
context.log.info("Executing", [cmd, ...args]);
|
|
97
|
+
context.log.info("Execution options", childOptions);
|
|
101
98
|
const child = (0, import_node_child_process.spawn)(cmd, args, childOptions);
|
|
102
99
|
if (child.stdout) {
|
|
103
100
|
const out = import_node_readline.default.createInterface(child.stdout);
|
|
104
|
-
out.on("line", (line) => line ?
|
|
101
|
+
out.on("line", (line) => line ? context.log.notice(line) : context.log.notice("\xA0"));
|
|
105
102
|
}
|
|
106
103
|
if (child.stderr) {
|
|
107
104
|
const err = import_node_readline.default.createInterface(child.stderr);
|
|
108
|
-
err.on("line", (line) => line ?
|
|
105
|
+
err.on("line", (line) => line ? context.log.warn(line) : context.log.warn("\xA0"));
|
|
109
106
|
}
|
|
110
107
|
return new Promise((resolve, reject) => {
|
|
111
108
|
child.on("error", (error) => reject(error));
|
|
@@ -122,7 +119,6 @@ async function spawnChild(cmd, args, options = {}, run) {
|
|
|
122
119
|
}
|
|
123
120
|
// Annotate the CommonJS export names for ESM import in node:
|
|
124
121
|
0 && (module.exports = {
|
|
125
|
-
Exec,
|
|
126
122
|
exec
|
|
127
123
|
});
|
|
128
124
|
//# sourceMappingURL=exec.cjs.map
|
package/dist/plugs/exec.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/plugs/exec.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AACjB,2BAAsB;AAEtB,gCAAoC;AACpC,oBAAuB;AAEvB,iBAA+B;AAC/B,mBAA2E;AAC3E,kBAAuD;AACvD,qBAA6B;AAC7B,mBAA+B;AAAA,IA6E/B,qBAAQ,QAAQ,MAAM,KAA4B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,eAAe,MAA8B;AAC3C,UAAM,EAAE,QAAQ,QAAQ,QAAI,6BAAa,MAAM,CAAC,CAAC;AACjD,UAAM,CAAE,SAAS,KAAM,IAAI;AAC3B,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,MAAM,KAAK,OAAc,SAAkC;AACzD,UAAM,EAAE,gBAAgB,SAAS,QAAQ,IAAI,KAAK;AAElD,QAAI,CAAE,QAAQ;AAAK,cAAQ,MAAM,MAAM;AAGvC,UAAM,SAAS,CAAE,GAAI,gBAAgB,QAAQ,MAAM,cAAc,CAAI;AAGrE,QAAI,QAAQ;AAAO,aAAO,QAAQ,CAAC,GAAG,GAAG,MA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,aAAa,CAAE,KAAK,GAAG,IAAK,CAAC;AAC9C,UAAQ,IAAI,KAAK,qBAAqB,YAAY;AAClD,QAAM,YAAQ,iCAAM,KAAK,MAAM,YAAY;AAE3C,MAAI,MAAM,QAAQ;AAChB,UAAM,MAAM,qBAAAC,QAAU,gBAAgB,MAAM,MAAM;AAClD,QAAI,GAAG,QAAQ,CAAC,SAAS,OAAO,QAAQ,IAAI,OAAO,IAAI,IAAI,QAAQ,IAAI,OAAO,MAAQ,CAAC;AAAA,EACzF;AAEA,MAAI,MAAM,QAAQ;AAChB,UAAM,MAAM,qBAAAA,QAAU,gBAAgB,MAAM,MAAM;AAClD,QAAI,GAAG,QAAQ,CAAC,SAAS,OAAO,QAAQ,IAAI,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,MAAQ,CAAC;AAAA,EACrF;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": ["path", "reaadline"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** Options for executing scripts */
|
|
2
|
+
export interface ExecOptions {
|
|
3
|
+
/** Extra environment variables, or overrides for existing ones */
|
|
4
|
+
env?: Record<string, any>;
|
|
5
|
+
/** Whether to run in the context of a _shell_ or not */
|
|
6
|
+
shell?: string | boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The current working directory of the process to execute.
|
|
9
|
+
*
|
|
10
|
+
* Defaults to the current {@link Files.directory | Files' directory} when
|
|
11
|
+
* used as a {@link Plug} or `process.cwd()` when used from {@link exec}.
|
|
12
|
+
*/
|
|
13
|
+
cwd?: string;
|
|
14
|
+
/**
|
|
15
|
+
* When used as a {@link Plug}, the {@link Files} will be appended to the
|
|
16
|
+
* current arguments as _relative_ files (default) or _absolute_ (if false).
|
|
17
|
+
*/
|
|
18
|
+
relativePaths?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare module '../pipe' {
|
|
21
|
+
interface Pipe {
|
|
22
|
+
/**
|
|
23
|
+
* Execute a shell command, adding to its _arguments_ the list of files
|
|
24
|
+
* from the current pipe (much like `xargs` does on Unix systems).
|
|
25
|
+
*
|
|
26
|
+
* For example:
|
|
27
|
+
*
|
|
28
|
+
* ```
|
|
29
|
+
* import { build } from '@plugjs/plugjs'
|
|
30
|
+
*
|
|
31
|
+
* export default build({
|
|
32
|
+
* runme() {
|
|
33
|
+
* this.find('*.ts', { directory: 'src' })
|
|
34
|
+
* .exec('chmod', '755' })
|
|
35
|
+
* .exec('chown root:root', { shell: true })
|
|
36
|
+
* },
|
|
37
|
+
* })
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param cmd The command to execute
|
|
41
|
+
* @param args Any additional argument for the command to execute
|
|
42
|
+
*/
|
|
43
|
+
exec(cmd: string, ...args: string[]): Pipe;
|
|
44
|
+
/**
|
|
45
|
+
* Execute a shell command, adding to its _arguments_ the list of files
|
|
46
|
+
* from the current pipe (much like `xargs` does on Unix systems).
|
|
47
|
+
*
|
|
48
|
+
* For example:
|
|
49
|
+
*
|
|
50
|
+
* ```
|
|
51
|
+
* import { build } from '@plugjs/plugjs'
|
|
52
|
+
*
|
|
53
|
+
* export default build({
|
|
54
|
+
* runme() {
|
|
55
|
+
* this.find('*.ts', { directory: 'src' })
|
|
56
|
+
* .exec('chmod', '755' })
|
|
57
|
+
* .exec('chown root:root', { shell: true })
|
|
58
|
+
* },
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param cmd The command to execute
|
|
63
|
+
* @param args Any additional argument for the command to execute
|
|
64
|
+
* @param options Extra {@link ExecOptions | options} for process execution
|
|
65
|
+
*/
|
|
66
|
+
exec(cmd: string, ...extra: [...args: string[], options: ExecOptions]): Pipe;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Execute a command and await for its result from within a task.
|
|
71
|
+
*
|
|
72
|
+
* For example:
|
|
73
|
+
*
|
|
74
|
+
* ```
|
|
75
|
+
* import { exec } from '@plugjs/plugjs'
|
|
76
|
+
*
|
|
77
|
+
* export default build({
|
|
78
|
+
* async runme() {
|
|
79
|
+
* await exec('ls', '-la', '/')
|
|
80
|
+
* // or similarly letting the shell interpret the command
|
|
81
|
+
* await exec('ls -la /', { shell: true })
|
|
82
|
+
* },
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param cmd The command to execute
|
|
87
|
+
* @param args Any additional argument for the command to execute
|
|
88
|
+
* @param options Extra {@link ExecOptions | options} for process execution
|
|
89
|
+
*/
|
|
90
|
+
export declare function exec(cmd: string, ...args: [...args: string[]] | [...args: string[], options: ExecOptions]): Promise<void>;
|