Skip to content

Commit 9778a53

Browse files
wraithgarlukekarrys
authored andcommitted
1 parent d8d374d commit 9778a53

File tree

12 files changed

+450
-68
lines changed

12 files changed

+450
-68
lines changed

node_modules/init-package-json/lib/default-input.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ function niceName (n) {
1717

1818
function readDeps (test, excluded) {
1919
return function (cb) {
20-
fs.readdir('node_modules', function (er, dir) {
21-
if (er) {
20+
fs.readdir('node_modules', function (readdirErr, dir) {
21+
if (readdirErr) {
2222
return cb()
2323
}
2424
var deps = {}
@@ -35,8 +35,8 @@ function readDeps (test, excluded) {
3535
}
3636

3737
var dp = path.join(dirname, 'node_modules', d, 'package.json')
38-
fs.readFile(dp, 'utf8', function (er, p) {
39-
if (er) {
38+
fs.readFile(dp, 'utf8', function (readFileErr, p) {
39+
if (readFileErr) {
4040
return next()
4141
}
4242
try {
@@ -108,11 +108,11 @@ var version = package.version ||
108108
'1.0.0'
109109
exports.version = yes ?
110110
version :
111-
prompt('version', version, function (version) {
112-
if (semver.valid(version)) {
113-
return version
111+
prompt('version', version, function (promptedVersion) {
112+
if (semver.valid(promptedVersion)) {
113+
return promptedVersion
114114
}
115-
var er = new Error('Invalid version: "' + version + '"')
115+
var er = new Error('Invalid version: "' + promptedVersion + '"')
116116
er.notValid = true
117117
return er
118118
})
@@ -128,8 +128,8 @@ if (!package.main) {
128128
f = []
129129
}
130130

131-
f = f.filter(function (f) {
132-
return f.match(/\.js$/)
131+
f = f.filter(function (filtered) {
132+
return filtered.match(/\.js$/)
133133
})
134134

135135
if (f.indexOf('index.js') !== -1) {
@@ -261,17 +261,17 @@ if (!package.repository) {
261261
}
262262

263263
if (!package.keywords) {
264-
exports.keywords = yes ? '' : prompt('keywords', function (s) {
265-
if (!s) {
264+
exports.keywords = yes ? '' : prompt('keywords', function (promptedKeywords) {
265+
if (!promptedKeywords) {
266266
return undefined
267267
}
268-
if (Array.isArray(s)) {
269-
s = s.join(' ')
268+
if (Array.isArray(promptedKeywords)) {
269+
promptedKeywords = promptedKeywords.join(' ')
270270
}
271-
if (typeof s !== 'string') {
272-
return s
271+
if (typeof promptedKeywords !== 'string') {
272+
return promptedKeywords
273273
}
274-
return s.split(/[\s,]+/)
274+
return promptedKeywords.split(/[\s,]+/)
275275
})
276276
}
277277

node_modules/init-package-json/lib/init-package-json.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,62 +74,62 @@ function init (dir, input, config, cb) {
7474
var pz = new PZ(input, ctx)
7575
pz.backupFile = def
7676
pz.on('error', cb)
77-
pz.on('data', function (data) {
78-
Object.keys(data).forEach(function (k) {
79-
if (data[k] !== undefined && data[k] !== null) {
80-
pkg[k] = data[k]
77+
pz.on('data', function (pzData) {
78+
Object.keys(pzData).forEach(function (k) {
79+
if (pzData[k] !== undefined && pzData[k] !== null) {
80+
pkg[k] = pzData[k]
8181
}
8282
})
8383

8484
// only do a few of these.
8585
// no need for mans or contributors if they're in the files
86-
var es = readJson.extraSet
86+
es = readJson.extraSet
8787
readJson.extraSet = es.filter(function (fn) {
8888
return fn.name !== 'authors' && fn.name !== 'mans'
8989
})
90-
readJson.extras(packageFile, pkg, function (er, pkg) {
91-
if (er) {
92-
return cb(er, pkg)
90+
readJson.extras(packageFile, pkg, function (extrasErr, pkgWithExtras) {
91+
if (extrasErr) {
92+
return cb(extrasErr, pkgWithExtras)
9393
}
9494
readJson.extraSet = es
95-
pkg = unParsePeople(pkg)
95+
pkgWithExtras = unParsePeople(pkgWithExtras)
9696
// no need for the readme now.
97-
delete pkg.readme
98-
delete pkg.readmeFilename
97+
delete pkgWithExtras.readme
98+
delete pkgWithExtras.readmeFilename
9999

100100
// really don't want to have this lying around in the file
101-
delete pkg._id
101+
delete pkgWithExtras._id
102102

103103
// ditto
104-
delete pkg.gitHead
104+
delete pkgWithExtras.gitHead
105105

106106
// if the repo is empty, remove it.
107-
if (!pkg.repository) {
108-
delete pkg.repository
107+
if (!pkgWithExtras.repository) {
108+
delete pkgWithExtras.repository
109109
}
110110

111111
// readJson filters out empty descriptions, but init-package-json
112112
// traditionally leaves them alone
113-
if (!pkg.description) {
114-
pkg.description = data.description
113+
if (!pkgWithExtras.description) {
114+
pkgWithExtras.description = pzData.description
115115
}
116116

117-
var d = JSON.stringify(updateDeps(pkg), null, 2) + '\n'
118-
function write (yes) {
119-
fs.writeFile(packageFile, d, 'utf8', function (er) {
120-
if (!er && yes && !config.get('silent')) {
121-
console.log('Wrote to %s:\n\n%s\n', packageFile, d)
117+
var stringified = JSON.stringify(updateDeps(pkgWithExtras), null, 2) + '\n'
118+
function write (writeYes) {
119+
fs.writeFile(packageFile, stringified, 'utf8', function (writeFileErr) {
120+
if (!writeFileErr && writeYes && !config.get('silent')) {
121+
console.log('Wrote to %s:\n\n%s\n', packageFile, stringified)
122122
}
123-
return cb(er, pkg)
123+
return cb(writeFileErr, pkgWithExtras)
124124
})
125125
}
126126
if (ctx.yes) {
127127
return write(true)
128128
}
129-
console.log('About to write to %s:\n\n%s\n', packageFile, d)
130-
read({ prompt: 'Is this OK? ', default: 'yes' }, function (er, ok) {
131-
if (er) {
132-
return cb(er)
129+
console.log('About to write to %s:\n\n%s\n', packageFile, stringified)
130+
read({ prompt: 'Is this OK? ', default: 'yes' }, function (promptErr, ok) {
131+
if (promptErr) {
132+
return cb(promptErr)
133133
}
134134
if (!ok || ok.toLowerCase().charAt(0) !== 'y') {
135135
console.log('Aborted.')
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2015 Julian Gruber <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# builtins
2+
3+
[![CI](https://github.com/juliangruber/builtins/actions/workflows/ci.yml/badge.svg)](https://github.com/juliangruber/builtins/actions/workflows/ci.yml)
4+
5+
List of node.js [builtin modules](http://nodejs.org/api/).
6+
7+
## Usage
8+
9+
```js
10+
const builtins = require('builtins')
11+
```
12+
13+
Get list of core modules for current Node.js version:
14+
15+
```js
16+
assert(builtins().includes('http'))
17+
```
18+
19+
Get list of core modules for specific Node.js version:
20+
21+
```js
22+
assert(builtins({ version: '6.0.0' }).includes('http'))
23+
```
24+
25+
Get list of core modules present in one or mode Node.js versions:
26+
27+
```js
28+
assert(builtins({ version: '*' }).includes('worker_threads'))
29+
```
30+
31+
Add experimental modules to the list:
32+
33+
```js
34+
assert(builtins({ experimental: true }).includes('wasi'))
35+
```
36+
37+
## License
38+
39+
MIT
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
'use strict'
2+
3+
const semver = require('semver')
4+
5+
const permanentModules = [
6+
'assert',
7+
'buffer',
8+
'child_process',
9+
'cluster',
10+
'console',
11+
'constants',
12+
'crypto',
13+
'dgram',
14+
'dns',
15+
'domain',
16+
'events',
17+
'fs',
18+
'http',
19+
'https',
20+
'module',
21+
'net',
22+
'os',
23+
'path',
24+
'punycode',
25+
'querystring',
26+
'readline',
27+
'repl',
28+
'stream',
29+
'string_decoder',
30+
'sys',
31+
'timers',
32+
'tls',
33+
'tty',
34+
'url',
35+
'util',
36+
'vm',
37+
'zlib'
38+
]
39+
40+
const versionLockedModules = {
41+
freelist: '<6.0.0',
42+
v8: '>=1.0.0',
43+
process: '>=1.1.0',
44+
inspector: '>=8.0.0',
45+
async_hooks: '>=8.1.0',
46+
http2: '>=8.4.0',
47+
perf_hooks: '>=8.5.0',
48+
trace_events: '>=10.0.0',
49+
worker_threads: '>=12.0.0'
50+
}
51+
52+
const experimentalModules = {
53+
worker_threads: '>=10.5.0',
54+
wasi: '>=12.16.0',
55+
diagnostics_channel: '^14.17.0 || >=15.1.0'
56+
}
57+
58+
module.exports = ({ version = process.version, experimental = false } = {}) => {
59+
const builtins = [...permanentModules]
60+
61+
for (const [name, semverRange] of Object.entries(versionLockedModules)) {
62+
if (version === '*' || semver.satisfies(version, semverRange)) {
63+
builtins.push(name)
64+
}
65+
}
66+
67+
if (experimental) {
68+
for (const [name, semverRange] of Object.entries(experimentalModules)) {
69+
if (
70+
!builtins.includes(name) &&
71+
(version === '*' || semver.satisfies(version, semverRange))
72+
) {
73+
builtins.push(name)
74+
}
75+
}
76+
}
77+
78+
return builtins
79+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "builtins",
3+
"version": "5.0.0",
4+
"description": "List of node.js builtin modules",
5+
"repository": "juliangruber/builtins",
6+
"license": "MIT",
7+
"main": "index.js",
8+
"files": [],
9+
"scripts": {
10+
"test": "prettier-standard && standard && node test.js"
11+
},
12+
"dependencies": {
13+
"semver": "^7.0.0"
14+
},
15+
"devDependencies": {
16+
"node-core-test": "^1.1.1",
17+
"prettier-standard": "^15.0.1",
18+
"standard": "^14.3.4"
19+
}
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Copyright (c) 2015, npm, Inc
2+
3+
4+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
5+
6+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

0 commit comments

Comments
 (0)