textrun-make 0.1.0 → 0.2.0

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.
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trimDollar = exports.getMakeTargets = exports.command = void 0;
4
- const color = require("colorette");
5
- const fs_1 = require("fs");
6
- const os = require("os");
7
- const tr = require("text-runner-core");
8
- const makefile_targets_1 = require("../helpers/makefile-targets");
1
+ import * as color from "colorette";
2
+ import { promises as fs } from "fs";
3
+ import * as os from "os";
4
+ import * as textRunner from "text-runner-core";
5
+ import { makefileTargets } from "../helpers/makefile-targets.js";
9
6
  /** verifies that the Makefile in the sourceDir contains the enclosed target */
10
- async function command(action) {
7
+ export async function command(action) {
11
8
  const wants = getMakeTargets(action.region.text());
12
9
  if (wants.length === 0) {
13
- throw new tr.UserError("No Make commands found", `Make commands must start with "make"`, action.location);
10
+ throw new textRunner.UserError("No Make commands found", `Make commands must start with "make"`, action.location);
14
11
  }
15
12
  else if (wants.length === 1) {
16
13
  action.name(`make command: ${color.cyan(wants[0])}`);
@@ -19,16 +16,15 @@ async function command(action) {
19
16
  action.name(`make commands: ${color.cyan(wants.join(", "))}`);
20
17
  }
21
18
  const makefilePath = action.configuration.sourceDir.joinStr(action.location.file.directory().platformified(), action.region[0].attributes["dir"] || ".", "Makefile");
22
- const makefileContent = await fs_1.promises.readFile(makefilePath, "utf8");
23
- const haves = makefile_targets_1.makefileTargets(makefileContent);
19
+ const makefileContent = await fs.readFile(makefilePath, "utf8");
20
+ const haves = makefileTargets(makefileContent);
24
21
  for (const want of wants) {
25
22
  if (!haves.includes(want)) {
26
23
  throw new Error(`Makefile does not contain command make ${color.cyan(want)} but these targets: ${color.cyan(haves.join(", "))}`);
27
24
  }
28
25
  }
29
26
  }
30
- exports.command = command;
31
- function getMakeTargets(code) {
27
+ export function getMakeTargets(code) {
32
28
  const result = [];
33
29
  for (let line of code.split(os.EOL)) {
34
30
  line = trimDollar(line.trim());
@@ -38,10 +34,8 @@ function getMakeTargets(code) {
38
34
  }
39
35
  return result;
40
36
  }
41
- exports.getMakeTargets = getMakeTargets;
42
37
  /** trims the leading dollar from the given command */
43
- function trimDollar(text) {
38
+ export function trimDollar(text) {
44
39
  return text.replace(/^\$?\s*/, "");
45
40
  }
46
- exports.trimDollar = trimDollar;
47
41
  //# sourceMappingURL=command.js.map
@@ -1,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.target = void 0;
4
- const color = require("colorette");
5
- const fs_1 = require("fs");
6
- const makefile_targets_1 = require("../helpers/makefile-targets");
1
+ import * as color from "colorette";
2
+ import { promises as fs } from "fs";
3
+ import { makefileTargets } from "../helpers/makefile-targets.js";
7
4
  /** verifies that the Makefile in the sourceDir contains the enclosed target */
8
- async function target(action) {
5
+ export async function target(action) {
9
6
  const target = action.region.text().trim();
10
7
  if (target === "") {
11
8
  throw new Error("Empty make target");
12
9
  }
13
10
  action.name(`make target ${color.cyan(target)}`);
14
11
  const makePath = action.configuration.sourceDir.joinStr(action.region[0].attributes["dir"] || ".", "Makefile");
15
- const makefile = await fs_1.promises.readFile(makePath, "utf8");
16
- const targets = makefile_targets_1.makefileTargets(makefile);
12
+ const makefile = await fs.readFile(makePath, "utf8");
13
+ const targets = makefileTargets(makefile);
17
14
  if (!targets.includes(target)) {
18
15
  throw new Error(`Makefile does not contain target ${color.cyan(target)} but these ones: ${color.cyan(targets.join(", "))}`);
19
16
  }
20
17
  }
21
- exports.target = target;
22
18
  //# sourceMappingURL=target.js.map
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makefileTargets = void 0;
4
1
  /** provides the targets in the given Makefile content, sorted alphabetically */
5
- function makefileTargets(text) {
2
+ export function makefileTargets(text) {
6
3
  return text
7
4
  .split("\n")
8
5
  .filter((line) => !line.startsWith("\t"))
@@ -13,5 +10,4 @@ function makefileTargets(text) {
13
10
  .filter((line) => line.length > 0)
14
11
  .sort();
15
12
  }
16
- exports.makefileTargets = makefileTargets;
17
13
  //# sourceMappingURL=makefile-targets.js.map
package/dist/index.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textrunActions = void 0;
4
- const command_1 = require("./actions/command");
5
- const target_1 = require("./actions/target");
6
- exports.textrunActions = {
7
- command: command_1.command,
8
- target: target_1.target,
1
+ import { command } from "./actions/command.js";
2
+ import { target } from "./actions/target.js";
3
+ export const textrunActions = {
4
+ command,
5
+ target,
9
6
  };
10
7
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,24 +1,33 @@
1
1
  {
2
2
  "name": "textrun-make",
3
- "version": "0.1.0",
4
- "main": "dist/index.js",
3
+ "version": "0.2.0",
5
4
  "license": "ISC",
5
+ "type": "module",
6
+ "exports": "./dist/index.js",
6
7
  "files": [
7
8
  "dist/**/*.js"
8
9
  ],
10
+ "scripts": {
11
+ "build": "tsc -p tsconfig-build.json",
12
+ "clean": "rm -rf dist",
13
+ "cuke": "cucumber-js --format=progress",
14
+ "doc": "text-run static --format=summary && text-run dynamic --format=progress",
15
+ "fix": "eslint . --fix --ext=.ts --ignore-path=../.eslintignore && prettier --write .",
16
+ "lint": "prettier -l . && eslint . --ext=.ts --ignore-path=../.eslintignore && depcheck --config=../.depcheckrc",
17
+ "unit": "env NODE_NO_WARNINGS=1 mocha --reporter=dot 'src/**/*.test.ts'"
18
+ },
9
19
  "dependencies": {
10
- "text-runner-core": "5.0.0"
20
+ "colorette": "2.0.19",
21
+ "text-runner-core": "6.0.0"
11
22
  },
12
23
  "devDependencies": {
13
- "colorette": "1.2.2",
14
- "cucumber": "6.0.5",
15
- "mocha": "8.3.0",
16
- "shared-cucumber-steps": "0.0.0",
17
- "text-runner": "5.0.0",
18
- "textrun-action": "0.1.0",
19
- "textrun-extension": "0.1.0",
20
- "textrun-npm": "0.1.0",
21
- "textrun-workspace": "0.1.0"
24
+ "shared-cucumber-steps": "*",
25
+ "text-runner": "6.0.0",
26
+ "textrun-action": "0.2.0",
27
+ "textrun-extension": "0.2.0",
28
+ "textrun-npm": "0.2.0",
29
+ "textrun-workspace": "0.2.0",
30
+ "ts-node": "10.9.1"
22
31
  },
23
- "gitHead": "1196acaca38c929200160d352267f6e25b1df087"
32
+ "gitHead": "5434976346f2e02bc08c0a6ea9f7cbfa67d68c4e"
24
33
  }