Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: explicitly include type #302

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/init-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ async function init (dir,
delete pkg.content.repository
}

if (!pkg.content.type) {
pkg.content.type = 'commonjs'
}

// readJson filters out empty descriptions, but init-package-json
// traditionally leaves them alone
if (!pkg.content.description) {
Expand Down
2 changes: 2 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ t.test('the basics', async (t) => {
main: 'main.js',
config: { foo: 'bar' },
package: {},
type: 'commonjs',
})
})

Expand All @@ -47,6 +48,7 @@ t.test('no config', async (t) => {
main: 'main.js',
config: {},
package: {},
type: 'commonjs',
})
})

Expand Down
1 change: 1 addition & 0 deletions test/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ t.test('read in dependencies and dev deps', async (t) => {
main: 'index.js',
keywords: [],
license: 'ISC',
type: 'commonjs',
dependencies: {
tap: '*',
},
Expand Down
1 change: 1 addition & 0 deletions test/npm-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const EXPECTED = {
keywords: [],
author: 'npmbot <[email protected]> (http://npm.im/)',
license: 'WTFPL',
type: 'commonjs',
}

t.test('npm configuration values pulled from environment', async t => {
Expand Down