(args, { path })
| 78 | } |
| 79 | |
| 80 | async set (args, { path }) { |
| 81 | const setError = () => |
| 82 | this.usageError('npm pkg set expects a key=value pair of args.') |
| 83 | |
| 84 | if (!args.length) { |
| 85 | throw setError() |
| 86 | } |
| 87 | |
| 88 | const force = this.npm.config.get('force') |
| 89 | const json = this.npm.config.get('json') |
| 90 | const pkgJson = await PackageJson.load(path) |
| 91 | const q = new Queryable(pkgJson.content) |
| 92 | for (const arg of args) { |
| 93 | const [key, ...rest] = arg.split('=') |
| 94 | const value = rest.join('=') |
| 95 | if (!key || !value) { |
| 96 | throw setError() |
| 97 | } |
| 98 | |
| 99 | q.set(key, json ? JSON.parse(value) : value, { force }) |
| 100 | } |
| 101 | |
| 102 | return pkgJson.update(q.toJSON()) |
| 103 | } |
| 104 | |
| 105 | async delete (args, { path }) { |
| 106 | const setError = () => |
no test coverage detected