Skip to content

Instantly share code, notes, and snippets.

Avatar
🔮
only way out is through

isaacs isaacs

🔮
only way out is through
View GitHub Profile
View npm-package.npm
{"name":"hello-world-bespoke-archive-format","version":"1.0.0","main":"lib/index.js"}
console.log('hello, world!')
# hello-world-bespoke-archive-format
An example of a "hello world" program, but instead of being a tarball, it's
shown in the bespoke package format that npm *SHOULD* have used, instead of
tar.
One can be forgiven for not wanting to reinvent the wheel, but let this be a
lesson that, in fact, some wheels _ought_ to be reinvented, when the
View awwwwwyiss.txt
$ rm -rf .tap; _TAPJS_PROCESSINFO_EXCLUDE_='/(?!'$PWD'/lib/node-options-to-argv.cjs$)^.*$/' node --loader=./lib/esm.mjs test/node-options-to-argv.cjs
(node:41096) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
TAP version 13
1..7
ok 1 - should be equivalent
ok 2 - should be equivalent
ok 3 - should be equivalent
ok 4 - should be equivalent
ok 5 - should be equivalent
View fixtures-delete-node.js
const {Node} = require('../')
const tree = new Node({
path: '/some/path',
pkg: { dependencies: { foo: '' }},
children: [
{
pkg: {name:'foo',version:'1.2.3',dependencies:{bar:''}},
children: [{pkg: {name:'bar',version:'1.2.3'}}],
},
],
View fixtures-delete-node.js
const {Node} = require('../')
const tree = new Node({
path: '/some/path',
pkg: { dependencies: { foo: '' }},
children: [
{
pkg: {name:'foo',version:'1.2.3',dependencies:{bar:''}},
children: [{pkg: {name:'bar',version:'1.2.3'}}],
},
],
View gist:e1fdd2d2fadae662d1295b69c8932ba9
diff --git a/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js b/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js
index ed0e47daf..1d4e20292 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js
@@ -308,11 +308,13 @@ module.exports = cls => class VirtualLoader extends cls {
target,
pkg: target && target.package,
})
- link.extraneous = target.extraneous
- link.devOptional = target.devOptional
View gist:96a4b2c79060117ff9bfd38f06dc9e59
diff --git a/lib/can-place-dep.js b/lib/can-place-dep.js
index 6be59093..3291b6fb 100644
--- a/lib/can-place-dep.js
+++ b/lib/can-place-dep.js
@@ -145,7 +145,9 @@ class CanPlaceDep {
return CONFLICT
}
- if (targetEdge && !dep.satisfies(targetEdge) && targetEdge !== this.edge) {
+ // skip this test if there's a current node, because we might be able
View gist:eb4bfc298aefa3168bf366d7133039a1
diff --git a/node_modules/@npmcli/arborist/lib/can-place-dep.js b/node_modules/@npmcli/arborist/lib/can-place-dep.js
index 6be59093c..3291b6fbf 100644
--- a/node_modules/@npmcli/arborist/lib/can-place-dep.js
+++ b/node_modules/@npmcli/arborist/lib/can-place-dep.js
@@ -145,7 +145,9 @@ class CanPlaceDep {
return CONFLICT
}
- if (targetEdge && !dep.satisfies(targetEdge) && targetEdge !== this.edge) {
+ // skip this test if there's a current node, because we might be able
View gist:fa2b4ca323aa1886af77d0b7991c8ef9
diff --git a/lib/can-place-dep.js b/lib/can-place-dep.js
index 6be59093..e4eba7ac 100644
--- a/lib/can-place-dep.js
+++ b/lib/can-place-dep.js
@@ -145,7 +145,9 @@ class CanPlaceDep {
return CONFLICT
}
- if (targetEdge && !dep.satisfies(targetEdge) && targetEdge !== this.edge) {
+ // skip this test if there's a current node, because we might be able
View gist:b29d60ef633fce24af13656072903bcf
diff --git a/index.js b/index.js
new file mode 100644
index 000000000..5447643e0
--- /dev/null
+++ b/index.js
@@ -0,0 +1,5 @@
+if (require.main === module) {
+ require('./lib/cli.js')(process)
+} else {
+ throw new Error('The programmatic API was removed in npm v8.0.0')
View node-version-preinstall.js
#!/usr/bin/env node
/*
put this in your package.json
"scripts": {
"preinstall": "node node-version-preinstall.js"
}
*/