| 153 | } |
| 154 | |
| 155 | async template (path = process.cwd()) { |
| 156 | const initFile = this.npm.config.get('init-module') |
| 157 | if (!this.npm.config.get('yes') && !this.npm.config.get('force')) { |
| 158 | output.standard([ |
| 159 | 'This utility will walk you through creating a package.json file.', |
| 160 | 'It only covers the most common items, and tries to guess sensible defaults.', |
| 161 | '', |
| 162 | 'See `npm help init` for definitive documentation on these fields and exactly what they do.', |
| 163 | '', |
| 164 | 'Use `npm install <pkg>` afterwards to install a package and save it as a dependency in the package.json file.', |
| 165 | '', |
| 166 | 'Press ^C at any time to quit.', |
| 167 | ].join('\n')) |
| 168 | } |
| 169 | |
| 170 | try { |
| 171 | const data = await input.read(() => initJson(path, initFile, this.npm.config)) |
| 172 | log.silly('package data', data) |
| 173 | return data |
| 174 | } catch (er) { |
| 175 | if (er.message === 'canceled') { |
| 176 | output.flush() |
| 177 | log.warn('init', 'canceled') |
| 178 | } else { |
| 179 | throw er |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | async setWorkspace (pkg, workspacePath) { |
| 185 | const workspaces = await mapWorkspaces({ cwd: this.npm.localPrefix, pkg }) |