libnpmexec 5.0.1 → 5.0.3

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/lib/index.js CHANGED
@@ -79,7 +79,6 @@ const exec = async (opts) => {
79
79
  const {
80
80
  args = [],
81
81
  call = '',
82
- color = false,
83
82
  localBin = resolve('./node_modules/.bin'),
84
83
  locationMsg = undefined,
85
84
  globalBin = '',
@@ -97,7 +96,6 @@ const exec = async (opts) => {
97
96
  const run = () => runScript({
98
97
  args,
99
98
  call,
100
- color,
101
99
  flatOptions,
102
100
  locationMsg,
103
101
  output,
@@ -114,20 +112,36 @@ const exec = async (opts) => {
114
112
 
115
113
  const needPackageCommandSwap = (args.length > 0) && (packages.length === 0)
116
114
  // If they asked for a command w/o specifying a package, see if there is a
117
- // bin that directly matches that name either globally or in the local tree.
115
+ // bin that directly matches that name:
116
+ // - in the local package itself
117
+ // - in the local tree
118
+ // - globally
118
119
  if (needPackageCommandSwap) {
119
- const dir = dirname(dirname(localBin))
120
- const localBinPath = await localFileExists(dir, args[0], '/')
121
- if (localBinPath) {
122
- binPaths.push(localBinPath)
123
- return await run()
124
- } else if (globalPath && await fileExists(`${globalBin}/${args[0]}`)) {
125
- binPaths.push(globalBin)
126
- return await run()
120
+ let localManifest
121
+ try {
122
+ localManifest = await pacote.manifest(path, flatOptions)
123
+ } catch {
124
+ // no local package.json? no problem, move one.
125
+ }
126
+ if (localManifest?.bin?.[args[0]]) {
127
+ // we have to install the local package into the npx cache so that its
128
+ // bin links get set up
129
+ packages.push(path)
130
+ yes = true
131
+ flatOptions.installLinks = false
132
+ } else {
133
+ const dir = dirname(dirname(localBin))
134
+ const localBinPath = await localFileExists(dir, args[0], '/')
135
+ if (localBinPath) {
136
+ binPaths.push(localBinPath)
137
+ return await run()
138
+ } else if (globalPath && await fileExists(`${globalBin}/${args[0]}`)) {
139
+ binPaths.push(globalBin)
140
+ return await run()
141
+ }
142
+ // We swap out args[0] with the bin from the manifest later
143
+ packages.push(args[0])
127
144
  }
128
-
129
- // We swap out args[0] with the bin from the manifest later
130
- packages.push(args[0])
131
145
  }
132
146
 
133
147
  // Resolve any directory specs so that the npx directory is unique to the
package/lib/run-script.js CHANGED
@@ -15,7 +15,6 @@ const nocolor = {
15
15
  const run = async ({
16
16
  args,
17
17
  call,
18
- color,
19
18
  flatOptions,
20
19
  locationMsg,
21
20
  output = () => {},
@@ -26,6 +25,7 @@ const run = async ({
26
25
  }) => {
27
26
  // turn list of args into command string
28
27
  const script = call || args.shift() || scriptShell
28
+ const color = !!flatOptions.color
29
29
  const colorize = color ? chalk : nocolor
30
30
 
31
31
  // do the fakey runScript dance
@@ -68,7 +68,6 @@ const run = async ({
68
68
  banner: false,
69
69
  // we always run in cwd, not --prefix
70
70
  path: runPath,
71
- stdioString: true,
72
71
  binPaths,
73
72
  event: 'npx',
74
73
  args,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libnpmexec",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "files": [
5
5
  "bin/",
6
6
  "lib/"
@@ -51,16 +51,16 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@npmcli/eslint-config": "^4.0.0",
54
- "@npmcli/template-oss": "4.6.2",
54
+ "@npmcli/template-oss": "4.9.0",
55
55
  "bin-links": "^4.0.1",
56
56
  "minify-registry-metadata": "^2.2.0",
57
57
  "mkdirp": "^1.0.4",
58
58
  "tap": "^16.0.1"
59
59
  },
60
60
  "dependencies": {
61
- "@npmcli/arborist": "^6.1.0",
62
- "@npmcli/ci-detect": "^3.0.0",
63
- "@npmcli/run-script": "^5.0.0",
61
+ "@npmcli/arborist": "^6.1.2",
62
+ "@npmcli/ci-detect": "^3.0.1",
63
+ "@npmcli/run-script": "^6.0.0",
64
64
  "chalk": "^4.1.0",
65
65
  "npm-package-arg": "^10.0.0",
66
66
  "npmlog": "^7.0.1",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  "templateOSS": {
75
75
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
76
- "version": "4.6.2",
76
+ "version": "4.9.0",
77
77
  "content": "../../scripts/template-oss/index.js"
78
78
  }
79
79
  }