ic-mops 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/init.js +11 -0
- package/package.json +1 -1
package/commands/init.js
CHANGED
|
@@ -4,6 +4,7 @@ import fs from 'fs';
|
|
|
4
4
|
import {checkApiCompatibility, mainActor, readDfxJson, writeConfig} from '../mops.js';
|
|
5
5
|
import {installAll} from './install-all.js';
|
|
6
6
|
import {readVesselConfig} from '../vessel.js';
|
|
7
|
+
import {execSync} from 'child_process';
|
|
7
8
|
|
|
8
9
|
export async function init(name = '') {
|
|
9
10
|
let configFile = path.join(process.cwd(), 'mops.toml');
|
|
@@ -64,6 +65,16 @@ export async function init(name = '') {
|
|
|
64
65
|
|
|
65
66
|
let dfxJson = readDfxJson();
|
|
66
67
|
let dfxVersion = dfxJson?.dfx || '';
|
|
68
|
+
if (!dfxVersion) {
|
|
69
|
+
try {
|
|
70
|
+
let res = execSync('dfx --version').toString();
|
|
71
|
+
let match = res.match(/\d+\.\d+\.\d+/);
|
|
72
|
+
if (match) {
|
|
73
|
+
dfxVersion = match[0];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {}
|
|
77
|
+
}
|
|
67
78
|
|
|
68
79
|
let actor = await mainActor();
|
|
69
80
|
let defaultPackages = await actor.getDefaultPackages(dfxVersion);
|