(logger, config)
| 10 | var createError = require('../util/createError'); |
| 11 | |
| 12 | function init(logger, config) { |
| 13 | var project; |
| 14 | |
| 15 | config = config || {}; |
| 16 | |
| 17 | if (!config.cwd) { |
| 18 | config.cwd = process.cwd(); |
| 19 | } |
| 20 | |
| 21 | config = defaultConfig(config); |
| 22 | |
| 23 | // This command requires interactive to be enabled |
| 24 | if (!config.interactive) { |
| 25 | throw createError('Register requires an interactive shell', 'ENOINT', { |
| 26 | details: |
| 27 | 'Note that you can manually force an interactive shell with --config.interactive' |
| 28 | }); |
| 29 | } |
| 30 | |
| 31 | project = new Project(config, logger); |
| 32 | |
| 33 | // Start with existing JSON details |
| 34 | return ( |
| 35 | readJson(project, logger) |
| 36 | // Fill in defaults |
| 37 | .then(setDefaults.bind(null, config)) |
| 38 | // Now prompt user to make changes |
| 39 | .then(promptUser.bind(null, logger)) |
| 40 | // Set ignore based on the response |
| 41 | .spread(setIgnore.bind(null, config)) |
| 42 | // Set dependencies based on the response |
| 43 | .spread(setDependencies.bind(null, project)) |
| 44 | // All done! |
| 45 | .spread(saveJson.bind(null, project, logger)) |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | function readJson(project, logger) { |
| 50 | return project.hasJson().then(function(json) { |
no test coverage detected
searching dependent graphs…