arcadible 1.0.12 → 1.0.13

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.
Files changed (2) hide show
  1. package/bin/arc.js +24 -9
  2. package/package.json +1 -1
package/bin/arc.js CHANGED
@@ -15,6 +15,7 @@ const phrase = require("../src/phrase");
15
15
  // [use]
16
16
 
17
17
  const pathExists = fs.pathExists;
18
+ const realpath = fs.realpath;
18
19
 
19
20
  // [declare]
20
21
 
@@ -47,16 +48,30 @@ const normalize = function (argv) {
47
48
 
48
49
  // [function]
49
50
 
51
+ // the script's own path, through any links: npm links only package.json's
52
+ // `bin` entries, so a command's sibling, such as `arc-default`, is found
53
+ // beside the real script, not beside the link that started it.
54
+ const resolve = function (argv) {
55
+ // left as it is when it can't be resolved, and reported as not found
56
+ return realpath(argv[1])
57
+ .catch(() => argv[1])
58
+ .then((file) => [argv[0], file, ...argv.slice(2)]);
59
+ };
60
+
61
+ // [function]
62
+
50
63
  const main = function (argv, load) {
51
- const args = normalize(dispatch(argv));
52
- pathExists(args[1], (err, exists) => {
53
- if (err || !exists) {
54
- log.hd(phrase.aborted("command"));
55
- log.pd(phrase.unableToFind(args[1]));
56
- process.exit(1);
57
- }
58
- const command = load(args[1]);
59
- command.main(args);
64
+ return resolve(argv).then((resolved) => {
65
+ const args = normalize(dispatch(resolved));
66
+ pathExists(args[1], (err, exists) => {
67
+ if (err || !exists) {
68
+ log.hd(phrase.aborted("command"));
69
+ log.pd(phrase.unableToFind(args[1]));
70
+ process.exit(1);
71
+ }
72
+ const command = load(args[1]);
73
+ command.main(args);
74
+ });
60
75
  });
61
76
  };
62
77
 
package/package.json CHANGED
@@ -65,5 +65,5 @@
65
65
  "scripts": {
66
66
  "test": "node --test \"test/**/*.test.js\""
67
67
  },
68
- "version": "1.0.12"
68
+ "version": "1.0.13"
69
69
  }