Skip to content
This repository was archived by the owner on Apr 7, 2021. It is now read-only.

Commit ab77f6c

Browse files
authored
feat(save): remove all save-related functionality (#19)
Fixes: #17 BREAKING CHANGE: npx can no longer be used to save packages locally or globally. Use an actual package manager for that, instead.
1 parent 55d6a11 commit ab77f6c

File tree

3 files changed

+4
-72
lines changed

3 files changed

+4
-72
lines changed

README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## SYNOPSIS
66

7-
`npx [--package|-p <package>] [--cache <path>] [--save-dev|-D] [--save-prod|-P] [--save-optional|-O] [--save-bundle|-B] [--save-exact|-E] [--global|-g] [--prefix|-C] [--userconfig <path>] [-c <string>] [--ignore-existing] [--version|-v] [--] <command>[@version] [command-arg]...`
7+
`npx [--package|-p <package>] [--cache <path>] [--userconfig <path>] [-c <string>] [--shell|-s <string>] [--shell-auto-fallback [shell]] [--ignore-existing] [--version|-v] [--] <command>[@version] [command-arg]...`
88

99
## INSTALL
1010

@@ -26,10 +26,6 @@ If a version specifier is included, or if `--package` is used, npx will ignore t
2626

2727
* `-g, --global` - install the package globally before execution.
2828

29-
* `-D, --save-dev, -P, --save-prod, -O, --save-optional, -B, --save-bundle, -E, --save-exact` - install the package in the current npm project and save it to `package.json` following the same option conventions for this as `npm install` would.
30-
31-
* `-C, --prefix` - The location to install global items. If used without `-g`, will force any installs to run in the specified folder. Defaults to whatever npm's default is.
32-
3329
* `--userconfig` - path to the user configuration file to pass to npm. Defaults to whatever npm's current default is.
3430

3531
* `-c <string>` - Execute `<string>` inside a shell. For unix, this will be `/bin/sh -c <string>`. For Windows, it will be `cmd.exe /d /s /c <string>`. Only the first item in `<string>` will be automatically used as `<command>`. Any others _must_ use `-p`.
@@ -60,14 +56,6 @@ $ cat package.json
6056
...webpack not in "devDependencies"...
6157
```
6258

63-
### Execute binary and add it to package.json as a devDependency
64-
65-
```
66-
$ npx -D webpack -- ...
67-
$ cat package.json
68-
...webpack added to "devDependencies"
69-
```
70-
7159
### Execute a full shell command using one npx call
7260

7361
```

index.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,7 @@ function getCmdPath (command, spec, npmOpts) {
7171
}
7272

7373
function getExistingPath (command, opts) {
74-
if (
75-
opts.saveProd ||
76-
opts.saveDev ||
77-
opts.saveOptional ||
78-
opts.saveBundle ||
79-
opts.saveExact ||
80-
opts.global ||
81-
opts.prefix ||
82-
opts.cmdHadVersion ||
83-
opts.packageRequested ||
84-
opts.ignoreExisting
85-
) {
74+
if (opts.cmdHadVersion || opts.packageRequested || opts.ignoreExisting) {
8675
return BB.resolve(false)
8776
} else {
8877
return which(command).catch({code: 'ENOENT'}, () => false)
@@ -103,17 +92,7 @@ function getNpmCache (opts) {
10392

10493
function buildArgs (spec, prefix, opts) {
10594
const args = ['install', spec]
106-
if (opts.saveProd) args.push('--save', '--save-prod')
107-
if (opts.saveDev) args.push('--save-dev')
108-
if (opts.saveOptional) args.push('--save-optional')
109-
if (opts.saveBundle) args.push('--save-bundle')
110-
if (opts.saveExact) args.push('--save-exact')
111-
if (opts.global) args.push('--global')
112-
if (opts.prefix) args.push('--prefix', opts.prefix)
113-
if (args.length === 2) {
114-
// No save opts passed in. Save it to the SUPERSEKRIT cache
115-
args.push('--global', '--prefix', prefix)
116-
}
95+
args.push('--global', '--prefix', prefix)
11796
if (opts.cache) args.push('--cache', opts.cache)
11897
if (opts.userconfig) args.push('--userconfig', opts.userconfig)
11998
args.push('--loglevel', 'error')

parse-args.js

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const npa = require('npm-package-arg')
44
const yargs = require('yargs')
55

6-
const usage = `$0 [--package|-p <package>] [--cache <path>] [--save-dev|-D] [--save-prod|-P] [--save-optional|-O] [--save-bundle|-B] [--save-exact|-E] [--global|-g] [--prefix|-C] [--userconfig <path>] [-c <string>] [--shell-auto-fallback [shell]] [--ignore-existing] [--version|-v] [--] <command>[@version] [command-arg]...`
6+
const usage = `$0 [--package|-p <package>] [--cache <path>] [--userconfig <path>] [-c <string>] [--shell <string>] [--shell-auto-fallback [shell]] [--ignore-existing] [--version|-v] [--] <command>[@version] [command-arg]...`
77

88
module.exports = parseArgs
99
function parseArgs () {
@@ -18,41 +18,6 @@ function parseArgs () {
1818
type: 'string',
1919
describe: 'location of the npm cache'
2020
})
21-
.option('save-prod', {
22-
alias: 'P',
23-
type: 'boolean',
24-
describe: 'add to project\'s dependencies'
25-
})
26-
.option('save-dev', {
27-
alias: 'D',
28-
type: 'boolean',
29-
describe: 'add to project\'s devDependencies'
30-
})
31-
.option('save-optional', {
32-
alias: 'O',
33-
type: 'boolean',
34-
describe: 'add to project\'s optionalDependencies'
35-
})
36-
.option('save-bundle', {
37-
alias: 'B',
38-
type: 'boolean',
39-
describe: 'add to project\'s bundleDependencies'
40-
})
41-
.option('save-exact', {
42-
alias: 'E',
43-
type: 'boolean',
44-
describe: 'save the exact specifier instead of a semver range'
45-
})
46-
.option('global', {
47-
alias: 'g',
48-
type: 'boolean',
49-
describe: 'install the package globally'
50-
})
51-
.option('prefix', {
52-
alias: 'C',
53-
type: 'boolean',
54-
describe: 'location to install global items, or where to run the install if not used with -g'
55-
})
5621
.option('userconfig', {
5722
type: 'string',
5823
describe: 'path to user npmrc'

0 commit comments

Comments
 (0)