+32
-17
lines changedFilter options
+32
-17
lines changed Original file line number Diff line number Diff line change
@@ -199,16 +199,17 @@ if (!package.scripts) {
199
199
200
200
if (!package.repository) {
201
201
exports.repository = async () => {
202
-
const gconf = await fs.readFile('.git/config', 'utf8').catch(() => '')
202
+
const gitConfigPath = path.resolve(dirname, '.git', 'config')
203
+
const gconf = await fs.readFile(gitConfigPath, 'utf8').catch(() => '')
203
204
const lines = gconf.split(/\r?\n/)
204
205
205
206
let url
206
207
const i = lines.indexOf('[remote "origin"]')
207
208
208
209
if (i !== -1) {
209
-
url = gconf[i + 1]
210
+
url = lines[i + 1]
210
211
if (!url.match(/^\s*url =/)) {
211
-
url = gconf[i + 2]
212
+
url = lines[i + 2]
212
213
}
213
214
if (!url.match(/^\s*url =/)) {
214
215
url = null
@@ -260,3 +261,8 @@ exports.license = yes ? license : prompt('license', license, (data) => {
260
261
const errors = (its.errors || []).concat(its.warnings || [])
261
262
return invalid(`Sorry, ${errors.join(' and ')}.`)
262
263
})
264
+
265
+
const type = package.type || getConfig('type') || 'commonjs'
266
+
exports.type = yes ? type : prompt('type', type, (data) => {
267
+
return data
268
+
})
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ async function init (dir,
139
139
return
140
140
}
141
141
142
-
await pkg.save()
142
+
await pkg.save({ sort: true })
143
143
return pkg.content
144
144
}
145
145
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "init-package-json",
3
-
"version": "7.0.1",
3
+
"version": "8.0.0",
4
4
"main": "lib/init-package-json.js",
5
5
"scripts": {
6
6
"test": "tap",
@@ -20,7 +20,7 @@
20
20
"license": "ISC",
21
21
"description": "A node module to get your node module started",
22
22
"dependencies": {
23
-
"@npmcli/package-json": "^6.0.0",
23
+
"@npmcli/package-json": "^6.1.0",
24
24
"npm-package-arg": "^12.0.0",
25
25
"promzard": "^2.0.0",
26
26
"read": "^4.0.0",
@@ -29,13 +29,13 @@
29
29
"validate-npm-package-name": "^6.0.0"
30
30
},
31
31
"devDependencies": {
32
-
"@npmcli/config": "^8.2.0",
32
+
"@npmcli/config": "^9.0.0",
33
33
"@npmcli/eslint-config": "^5.0.0",
34
-
"@npmcli/template-oss": "4.23.3",
34
+
"@npmcli/template-oss": "4.23.4",
35
35
"tap": "^16.0.1"
36
36
},
37
37
"engines": {
38
-
"node": "^18.17.0 || >=20.5.0"
38
+
"node": "^20.17.0 || >=22.9.0"
39
39
},
40
40
"tap": {
41
41
"test-ignore": "fixtures/",
@@ -61,7 +61,7 @@
61
61
],
62
62
"templateOSS": {
63
63
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
64
-
"version": "4.23.3",
64
+
"version": "4.23.4",
65
65
"publish": true
66
66
}
67
67
}
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@
106
106
"graceful-fs": "^4.2.11",
107
107
"hosted-git-info": "^8.0.2",
108
108
"ini": "^5.0.0",
109
-
"init-package-json": "^7.0.1",
109
+
"init-package-json": "^8.0.0",
110
110
"is-cidr": "^5.1.0",
111
111
"json-parse-even-better-errors": "^4.0.0",
112
112
"libnpmaccess": "^10.0.0-pre.0",
@@ -9195,13 +9195,13 @@
9195
9195
}
9196
9196
},
9197
9197
"node_modules/init-package-json": {
9198
-
"version": "7.0.1",
9199
-
"resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-7.0.1.tgz",
9200
-
"integrity": "sha512-8KZtk/53ReI2T2f6z2hl5ql6xKLjDexNw7DUqTdR8f+Mo8WZmBjjkH6DrTfBjmW0j3Tqx+j3t8creN0O890+0A==",
9198
+
"version": "8.0.0",
9199
+
"resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-8.0.0.tgz",
9200
+
"integrity": "sha512-zKgxfaGt6Zzi8VBSInOK0CYDigA9gzDCWPnSzGIoUlTU/5w7qIyi+6MyJYX96mMlxDGrIR85FhQszVyodYfB9g==",
9201
9201
"inBundle": true,
9202
9202
"license": "ISC",
9203
9203
"dependencies": {
9204
-
"@npmcli/package-json": "^6.0.0",
9204
+
"@npmcli/package-json": "^6.1.0",
9205
9205
"npm-package-arg": "^12.0.0",
9206
9206
"promzard": "^2.0.0",
9207
9207
"read": "^4.0.0",
@@ -9210,7 +9210,7 @@
9210
9210
"validate-npm-package-name": "^6.0.0"
9211
9211
},
9212
9212
"engines": {
9213
-
"node": "^18.17.0 || >=20.5.0"
9213
+
"node": "^20.17.0 || >=22.9.0"
9214
9214
}
9215
9215
},
9216
9216
"node_modules/internal-slot": {
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@
73
73
"graceful-fs": "^4.2.11",
74
74
"hosted-git-info": "^8.0.2",
75
75
"ini": "^5.0.0",
76
-
"init-package-json": "^7.0.1",
76
+
"init-package-json": "^8.0.0",
77
77
"is-cidr": "^5.1.0",
78
78
"json-parse-even-better-errors": "^4.0.0",
79
79
"libnpmaccess": "^10.0.0-pre.0",
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ Wrote to {NPM}/{TESTDIR}/project/package.json:
116
116
"keywords": [],
117
117
"author": "",
118
118
"license": "ISC",
119
+
"type": "commonjs",
119
120
"description": ""
120
121
}
121
122
`
@@ -171,6 +172,7 @@ Object {
171
172
"scripts": Object {
172
173
"test": "echo /"Error: no test specified/" && exit 1",
173
174
},
175
+
"type": "commonjs",
174
176
"version": "1.0.0",
175
177
}
176
178
`
@@ -223,6 +225,7 @@ Object {
223
225
"scripts": Object {
224
226
"test": "echo /"Error: no test specified/" && exit 1",
225
227
},
228
+
"type": "commonjs",
226
229
"version": "1.0.0",
227
230
}
228
231
`
@@ -253,6 +256,7 @@ Object {
253
256
"hello": "echo Hello",
254
257
"test": "echo /"Error: no test specified/" && exit 1",
255
258
},
259
+
"type": "commonjs",
256
260
"version": "1.0.0",
257
261
}
258
262
`
@@ -277,6 +281,7 @@ Object {
277
281
"LC_ALL=sk",
278
282
],
279
283
},
284
+
"type": "commonjs",
280
285
"version": "1.0.0",
281
286
}
282
287
`
@@ -305,6 +310,7 @@ exports[`test/index.js TAP basic npm pkg > should print package.json contents 1`
305
310
"keywords": [],
306
311
"author": "",
307
312
"license": "ISC",
313
+
"type": "commonjs",
308
314
"description": "",
309
315
"dependencies": {
310
316
"abbrev": "^1.0.4"
@@ -335,6 +341,7 @@ Object {
335
341
"hello": "echo Hello",
336
342
"test": "echo /"Error: no test specified/" && exit 1",
337
343
},
344
+
"type": "commonjs",
338
345
"version": "1.0.0",
339
346
}
340
347
`
@@ -392,6 +399,7 @@ Object {
392
399
"hello": "echo Hello",
393
400
"test": "echo /"Error: no test specified/" && exit 1",
394
401
},
402
+
"type": "commonjs",
395
403
"version": "1.0.0",
396
404
}
397
405
`
@@ -452,6 +460,7 @@ Object {
452
460
"hello": "echo Hello",
453
461
"test": "echo /"Error: no test specified/" && exit 1",
454
462
},
463
+
"type": "commonjs",
455
464
"version": "1.0.0",
456
465
}
457
466
`
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4