MCPcopy
hub / github.com/bower/bower / init

Function init

lib/commands/init.js:12–47  ·  view source on GitHub ↗
(logger, config)

Source from the content-addressed store, hash-verified

10var createError = require('../util/createError');
11
12function 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
49function readJson(project, logger) {
50 return project.hasJson().then(function(json) {

Callers 1

init.jsFile · 0.85

Calls 3

defaultConfigFunction · 0.85
readJsonFunction · 0.70
createErrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…