Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuy Adorno <ruyadorno@hotmail.com>2021-06-28 18:37:08 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-07-12 18:04:38 +0300
commitf17aca5cdf355aaa7e1f517d1b3bb4213f4df092 (patch)
treec3bbe8872bc9ec52a2fa24c3efb5cc2fb3d48ad5 /smoke-tests
parent74c99755e522f9cfc0d602841568d5e1f835fcaf (diff)
feat: npm pkg
Implements `npm pkg get|set|delete` support. It enables retrieving and modifying values in a `package.json` file of any given project. Included are the implementation based on https://github.com/npm/rfcs/pull/402 along with extensive tests and user documentation. Relates to: https://github.com/npm/rfcs/pull/402 Fixes: https://github.com/npm/statusboard/issues/368 PR-URL: https://github.com/npm/cli/pull/3487 Credit: @ruyadorno Close: #3487 Reviewed-by: @wraithgar
Diffstat (limited to 'smoke-tests')
-rw-r--r--smoke-tests/index.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/smoke-tests/index.js b/smoke-tests/index.js
index c7b2d2a1c..9235c8960 100644
--- a/smoke-tests/index.js
+++ b/smoke-tests/index.js
@@ -209,3 +209,35 @@ t.test('npm uninstall', async t => {
'should have expected uninstall lockfile result'
)
})
+
+t.test('npm pkg', async t => {
+ let cmd = `${npmBin} pkg get license`
+ let cmdRes = await exec(cmd)
+ t.matchSnapshot(cmdRes.replace(/in.*s/, ''),
+ 'should have expected pkg get output')
+
+ cmd = `${npmBin} pkg set tap[test-env][0]=LC_ALL=sk`
+ cmdRes = await exec(cmd)
+ t.matchSnapshot(cmdRes.replace(/in.*s/, ''),
+ 'should have expected pkg set output')
+
+ t.matchSnapshot(
+ readFile('package.json'),
+ 'should have expected npm pkg set modified package.json result'
+ )
+
+ cmd = `${npmBin} pkg get`
+ cmdRes = await exec(cmd)
+ t.matchSnapshot(cmdRes.replace(/in.*s/, ''),
+ 'should print package.json contents')
+
+ cmd = `${npmBin} pkg delete tap`
+ cmdRes = await exec(cmd)
+ t.matchSnapshot(cmdRes.replace(/in.*s/, ''),
+ 'should have expected pkg delete output')
+
+ t.matchSnapshot(
+ readFile('package.json'),
+ 'should have expected npm pkg delete modified package.json result'
+ )
+})