mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
fix command parsing for unknown flags (#70)
* fix command parsing for unknown flags * fix test case * add dev flag support for npm cmds
This commit is contained in:
@@ -44,7 +44,7 @@ func TestNpmParseCommand(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "install a development package with short flag",
|
||||
command: "npm i @types/node -D",
|
||||
command: "npm i -D @types/node",
|
||||
assert: func(t *testing.T, parsedCommand *ParsedCommand, err error) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(parsedCommand.InstallTargets))
|
||||
@@ -89,7 +89,7 @@ func TestNpmParseCommand(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "multiple development packages",
|
||||
command: "npm i @types/node @types/react -D",
|
||||
command: "npm i -D @types/node -D @types/react",
|
||||
assert: func(t *testing.T, parsedCommand *ParsedCommand, err error) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(parsedCommand.InstallTargets))
|
||||
@@ -128,12 +128,12 @@ func TestNpmParseCommand(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "npm install with flags but no packages",
|
||||
name: "npm install with dev flag but no packages",
|
||||
command: "npm install --save-dev",
|
||||
assert: func(t *testing.T, parsedCommand *ParsedCommand, err error) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, len(parsedCommand.InstallTargets))
|
||||
assert.Equal(t, true, parsedCommand.IsManifestInstall)
|
||||
assert.Equal(t, false, parsedCommand.IsManifestInstall) // with no package name, npm won’t add or install anything new
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user