MCPcopy
hub / github.com/acode/cli / run

Method run

cli/commands/download.js:58–225  ·  view source on GitHub ↗
(params, callback)

Source from the content-addressed store, hash-verified

56 }
57
58 run(params, callback) {
59
60 let service = params.args[0] || '';
61 if (!service) {
62 console.log();
63 console.log(chalk.bold.red('Oops!'));
64 console.log();
65 console.log(`Please specify a service name`);
66 console.log(`Use ${chalk.bold('username/name')} for latest release,`);
67 console.log(`Or ${chalk.bold('username/name@env')} or ${chalk.bold('username/name@version')} for specific environments and versions`);
68 console.log();
69 return callback(null);
70 }
71
72 let outputPath = params.flags.o || params.vflags.output || [];
73 outputPath = outputPath[0] || '.';
74
75 let write = params.flags.hasOwnProperty('w') || params.vflags.hasOwnProperty('write-over');
76
77 let pathname = path.join(outputPath, service);
78 pathname = outputPath[0] !== '/' ? path.join(process.cwd(), pathname) : pathname;
79
80 if (!config.location(0)) {
81 console.log();
82 console.log(chalk.bold.red('Oops!'));
83 console.log();
84 console.log(`You're trying to retrieve a package,`);
85 console.log(`But you're not in your root Autocode project directory.`);
86 console.log();
87 if (!config.workspace()) {
88 console.log(`Initialize a workspace first with:`);
89 console.log(`\t${chalk.bold('lib init')}`);
90 } else {
91 console.log('Visit your workspace directory with:');
92 console.log(`\t${chalk.bold('cd ' + config.workspace())}`);
93 }
94 console.log();
95 return callback(null);
96 }
97
98 if (!write && fs.existsSync(pathname)) {
99 console.log();
100 console.log(chalk.bold.red('Oops!'));
101 console.log();
102 console.log(`The directory you're retrieving to already exists:`);
103 console.log(` ${chalk.bold(pathname)}`);
104 console.log();
105 console.log(`Try removing the existing directory first.`);
106 console.log();
107 console.log(`Use ${chalk.bold('lib download ' + service + ' --write-over')} to override.`);
108 console.log();
109 return callback(null);
110 }
111
112 let host = 'packages.stdlib.com';
113 let port = 443;
114
115 let hostname = (params.flags.h && params.flags.h[0]) || '';

Callers

nothing calls this directly

Calls 6

requestMethod · 0.95
rmdirFunction · 0.85
locationMethod · 0.80
workspaceMethod · 0.80
getMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected