MCPcopy Index your code
hub / github.com/apache/cordova-cli / cli

Function cli

src/cli.js:145–352  ·  view source on GitHub ↗
(inputArgs)

Source from the content-addressed store, hash-verified

143}
144
145function cli (inputArgs) {
146 const args = nopt(knownOpts, shortHands, inputArgs);
147
148 process.on('uncaughtException', function (err) {
149 if (err.message) {
150 logger.error(err.message);
151 } else {
152 logger.error(err);
153 }
154 process.exit(1);
155 });
156
157 logger.subscribe(events);
158
159 if (args.silent) {
160 logger.setLevel('error');
161 } else if (args.verbose) { // can't be both silent AND verbose, silent wins
162 logger.setLevel('verbose');
163 }
164
165 const cliVersion = pkg.version;
166 const usingPrerelease = !!semver.prerelease(cliVersion);
167 if (args.version || usingPrerelease) {
168 const libVersion = require('cordova-lib/package').version;
169 let toPrint = cliVersion;
170 if (cliVersion !== libVersion || usingPrerelease) {
171 toPrint += ' (cordova-lib@' + libVersion + ')';
172 }
173
174 if (args.version) {
175 logger.results(toPrint);
176 return Promise.resolve(); // Important! this will return and cease execution
177 } else { // must be usingPrerelease
178 // Show a warning and continue
179 logger.warn('Warning: using prerelease version ' + toPrint);
180 }
181 }
182
183 let warningPartial = null;
184
185 // If the Node.js versions does not meet our requirements or in a deprecation stage, display a warning.
186 if (
187 NODE_VERSION_REQUIREMENT &&
188 !semver.satisfies(NODE_VERSION, NODE_VERSION_REQUIREMENT)
189 ) {
190 warningPartial = 'is no longer supported';
191 } else if (
192 NODE_VERSION_DEPRECATING_RANGE &&
193 semver.satisfies(NODE_VERSION, NODE_VERSION_DEPRECATING_RANGE)
194 ) {
195 warningPartial = 'has been deprecated';
196 }
197
198 if (warningPartial) {
199 const upgradeMsg = 'Please upgrade to the latest Node.js version available (LTS version recommended).';
200 logger.warn(`Warning: Node.js ${NODE_VERSION} ${warningPartial}. ${upgradeMsg}`);
201 }
202

Callers 2

cli.jsFile · 0.85
cli.spec.jsFile · 0.85

Calls 1

printHelpFunction · 0.85

Tested by

no test coverage detected