Skip to content

Commit

Permalink
feat: deprecated commands set-script and birthday
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzy committed May 10, 2022
1 parent f985dbb commit 34829f8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/content/commands/npm-set-script.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ description: Set tasks in the scripts section of package.json
### Synopsis
An npm command that lets you create a task in the `scripts` section of the `package.json`.

Deprecated.

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/set-script.js -->
Expand Down
4 changes: 3 additions & 1 deletion lib/commands/birthday.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const BaseCommand = require('../base-command.js')
const log = require('../utils/log-shim')

class Birthday extends BaseCommand {
static name = 'birthday'
static description = 'Birthday'
static description = 'Birthday, deprecated'
static ignoreImplicitWorkspace = true
static isShellout = true

async exec () {
log.warn('birthday', 'birthday is deprecated, and will be removed in a future version.')
this.npm.config.set('yes', true)
return this.npm.exec('exec', ['@npmcli/npm-birthday'])
}
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/set-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const log = require('../utils/log-shim')

const BaseCommand = require('../base-command.js')
class SetScript extends BaseCommand {
static description = 'Set tasks in the scripts section of package.json'
static description = 'Set tasks in the scripts section of package.json, deprecated'
static params = ['workspace', 'workspaces', 'include-workspace-root']
static name = 'set-script'
static usage = ['[<script>] [<command>]']
Expand Down Expand Up @@ -34,6 +34,7 @@ class SetScript extends BaseCommand {

async exec (args) {
this.validate(args)
log.warn('set-script', 'set-script is deprecated, and will be removed in a future version.')
const warn = await this.doSetScript(this.npm.localPrefix, args[0], args[1])
if (warn) {
log.warn('set-script', `Script "${args[0]}" was overwritten`)
Expand Down
4 changes: 2 additions & 2 deletions tap-snapshots/test/lib/load-all-commands.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Run "npm help bin" for more info
`

exports[`test/lib/load-all-commands.js TAP load each command birthday > must match snapshot 1`] = `
Birthday
Birthday, deprecated
Usage:
npm birthday
Expand Down Expand Up @@ -802,7 +802,7 @@ Run "npm help set" for more info
`

exports[`test/lib/load-all-commands.js TAP load each command set-script > must match snapshot 1`] = `
Set tasks in the scripts section of package.json
Set tasks in the scripts section of package.json, deprecated
Usage:
npm set-script [<script>] [<command>]
Expand Down
2 changes: 1 addition & 1 deletion tap-snapshots/test/lib/utils/npm-usage.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ All commands:
Run "npm help set" for more info
set-script Set tasks in the scripts section of package.json
set-script Set tasks in the scripts section of package.json, deprecated
Usage:
npm set-script [<script>] [<command>]
Expand Down
2 changes: 1 addition & 1 deletion test/lib/commands/set-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ t.test('warns when overwriting', async t => {
})

await setScript.exec(['arg1', 'arg2'])
t.hasStrict(WARN_OUTPUT[0], ['set-script', 'Script "arg1" was overwritten'], 'warning was logged')
t.hasStrict(WARN_OUTPUT[1], ['set-script', 'Script "arg1" was overwritten'], 'warning was logged')
})

t.test('workspaces', async t => {
Expand Down

0 comments on commit 34829f8

Please sign in to comment.