Skip to content

Commit 3a80a7b

Browse files
authoredFeb 4, 2025
feat: add --init-type flag (#8081)
1 parent 879303c commit 3a80a7b

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed
 

‎lib/commands/init.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Init extends BaseCommand {
1919
'init-author-url',
2020
'init-license',
2121
'init-module',
22+
'init-type',
2223
'init-version',
2324
'yes',
2425
'force',

‎tap-snapshots/test/lib/commands/config.js.test.cjs

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
7474
"init-author-url": "",
7575
"init-license": "ISC",
7676
"init-module": "{CWD}/home/.npm-init.js",
77+
"init-type": "commonjs",
7778
"init-version": "1.0.0",
7879
"init.author.email": "",
7980
"init.author.name": "",
@@ -237,6 +238,7 @@ init-author-name = ""
237238
init-author-url = ""
238239
init-license = "ISC"
239240
init-module = "{CWD}/home/.npm-init.js"
241+
init-type = "commonjs"
240242
init-version = "1.0.0"
241243
init.author.email = ""
242244
init.author.name = ""

‎tap-snapshots/test/lib/docs.js.test.cjs

+15-2
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,16 @@ more information, or [npm init](/commands/npm-init).
854854
855855
856856
857+
#### \`init-type\`
858+
859+
* Default: "commonjs"
860+
* Type: String
861+
862+
The value that \`npm init\` should use by default for the package.json type
863+
field.
864+
865+
866+
857867
#### \`init-version\`
858868
859869
* Default: "1.0.0"
@@ -2123,6 +2133,7 @@ Array [
21232133
"init-author-url",
21242134
"init-license",
21252135
"init-module",
2136+
"init-type",
21262137
"init-version",
21272138
"init.author.email",
21282139
"init.author.name",
@@ -2357,6 +2368,7 @@ Array [
23572368
"init-author-url",
23582369
"init-license",
23592370
"init-module",
2371+
"init-type",
23602372
"init-version",
23612373
"init.author.email",
23622374
"init.author.name",
@@ -3210,8 +3222,8 @@ npm init <@scope> (same as \`npx <@scope>/create\`)
32103222
32113223
Options:
32123224
[--init-author-name <name>] [--init-author-url <url>] [--init-license <license>]
3213-
[--init-module <module>] [--init-version <version>] [-y|--yes] [-f|--force]
3214-
[--scope <@scope>]
3225+
[--init-module <module>] [--init-type <type>] [--init-version <version>]
3226+
[-y|--yes] [-f|--force] [--scope <@scope>]
32153227
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
32163228
[--workspaces] [--no-workspaces-update] [--include-workspace-root]
32173229
@@ -3230,6 +3242,7 @@ aliases: create, innit
32303242
#### \`init-author-url\`
32313243
#### \`init-license\`
32323244
#### \`init-module\`
3245+
#### \`init-type\`
32333246
#### \`init-version\`
32343247
#### \`yes\`
32353248
#### \`force\`

‎workspaces/config/lib/definitions/definitions.js

+8
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,14 @@ const definitions = {
954954
more information, or [npm init](/commands/npm-init).
955955
`,
956956
}),
957+
'init-type': new Definition('init-type', {
958+
default: 'commonjs',
959+
type: String,
960+
hint: '<type>',
961+
description: `
962+
The value that \`npm init\` should use by default for the package.json type field.
963+
`,
964+
}),
957965
'init-version': new Definition('init-version', {
958966
default: '1.0.0',
959967
type: Semver,

‎workspaces/config/tap-snapshots/test/type-description.js.test.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ Object {
231231
"init-module": Array [
232232
"valid filesystem path",
233233
],
234+
"init-type": Array [
235+
Function String(),
236+
],
234237
"init-version": Array [
235238
"full valid SemVer string",
236239
],

0 commit comments

Comments
 (0)
Failed to load comments.