Skip to content

Commit 188fbcc

Browse files
committed
refactor: meta is generated by cli-utils
1 parent 327baed commit 188fbcc

4 files changed

Lines changed: 19 additions & 20 deletions

File tree

packages/cli-utils/src/definitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ export interface IonicEnvironment {
509509
readonly events: ICLIEventEmitter;
510510
readonly log: ILogger;
511511
readonly prompt: PromptModule;
512-
meta?: {
512+
meta: {
513513
local: boolean; // CLI running in local mode?
514514
binPath: string;
515515
libPath: string;

packages/cli-utils/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ export async function generateIonicEnvironment(plugin: RootPlugin, pargv: string
197197
hooks,
198198
load,
199199
log,
200+
meta: {
201+
local: env['IONIC_CLI_LOCAL'] ? true : false,
202+
binPath: env['IONIC_CLI_BIN'],
203+
libPath: env['IONIC_CLI_LIB'],
204+
},
200205
namespace: plugin.namespace,
201206
open,
202207
plugins: {

packages/ionic/bin/ionic

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ process.on('unhandledRejection', function(r) { console.error(r); });
88
var semver = require('semver');
99

1010
if (semver.lt(process.version, 'v6.4.0')) {
11-
var chalk = require('chalk');
12-
console.log(chalk.red('ERR') + ': Your Node.js version is ' + chalk.bold(process.version) + '. Please update to the latest Node 6 LTS version (or latest Node).');
11+
console.log('ERR: Your Node.js version is ' + process.version + '. Please update to the latest Node 6 LTS version (or latest Node).');
1312
process.exit(1);
1413
}
1514

1615
var bootstrap = require('@ionic/cli-utils/bootstrap');
1716

1817
bootstrap.detectLocalCLI().then(function(localPath) {
19-
var cli = require(localPath || '../');
18+
var cli = require(localPath ? localPath : '../');
19+
process.env.IONIC_CLI_LOCAL = localPath;
2020
process.env.IONIC_CLI_BIN = __filename;
21-
cli.run(process.argv, process.env, { local: localPath ? true : false });
21+
cli.run(process.argv, process.env);
2222
});

packages/ionic/src/index.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function registerHooks(hooks: IHookEngine) {
138138
}
139139

140140

141-
export async function run(pargv: string[], env: { [k: string]: string; }, opts: { local?: boolean; } = {}) {
141+
export async function run(pargv: string[], env: { [k: string]: string; }) {
142142
const now = new Date();
143143
let exitCode = 0;
144144
let err: any;
@@ -148,23 +148,17 @@ export async function run(pargv: string[], env: { [k: string]: string; }, opts:
148148

149149
const ienv = await generateIonicEnvironment(exports, pargv, env);
150150

151-
ienv.meta = {
152-
local: opts.local || false,
153-
binPath: env['IONIC_CLI_BIN'],
154-
libPath: env['IONIC_CLI_LIB'],
155-
};
156-
157-
registerHooks(ienv.hooks);
158-
159151
try {
160-
const configData = await ienv.config.load();
152+
const config = await ienv.config.load();
153+
154+
registerHooks(ienv.hooks);
161155

162156
ienv.log.debug(() => util.inspect(ienv.meta, { breakLength: Infinity, colors: chalk.enabled }));
163157

164158
if (env['IONIC_EMAIL'] && env['IONIC_PASSWORD']) {
165159
ienv.log.debug(() => `${chalk.bold('IONIC_EMAIL')} / ${chalk.bold('IONIC_PASSWORD')} environment variables detected`);
166160

167-
if (configData.user.email !== env['IONIC_EMAIL']) {
161+
if (config.user.email !== env['IONIC_EMAIL']) {
168162
ienv.log.debug(() => `${chalk.bold('IONIC_EMAIL')} mismatch with current session--attempting login`);
169163

170164
try {
@@ -214,18 +208,18 @@ export async function run(pargv: string[], env: { [k: string]: string; }, opts:
214208
}
215209

216210
if (ienv.flags.interactive) {
217-
if (typeof configData.daemon.updates === 'undefined') {
211+
if (typeof config.daemon.updates === 'undefined') {
218212
const confirm = await ienv.prompt({
219213
type: 'confirm',
220214
name: 'confirm',
221215
message: `The Ionic CLI can automatically check for CLI updates in the background. Would you like to enable this?`,
222216
});
223217

224-
configData.daemon.updates = confirm;
218+
config.daemon.updates = confirm;
225219
await ienv.config.save();
226220
}
227221

228-
if (configData.daemon.updates) {
222+
if (config.daemon.updates) {
229223
await Promise.all([checkForDaemon(ienv), checkForUpdates(ienv)]);
230224
}
231225
}
@@ -238,7 +232,7 @@ export async function run(pargv: string[], env: { [k: string]: string; }, opts:
238232
exitCode = r;
239233
}
240234

241-
configData.lastCommand = now.toISOString();
235+
config.lastCommand = now.toISOString();
242236
}
243237

244238
} catch (e) {

0 commit comments

Comments
 (0)