Skip to content

Commit

Permalink
do not await check env when activating edge extension
Browse files Browse the repository at this point in the history
  • Loading branch information
adashen committed Jun 22, 2018
1 parent 92637ec commit 62cf0f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 18 additions & 16 deletions src/edge/edgeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,27 @@ export class EdgeManager {
return;
}

const folderPath = folder.uri.fsPath;
if (folder) {
const deploymentTemplate = path.join(folderPath, Constants.deploymentTemplate);
const envFile = path.join(folderPath, Constants.envFile);
if (await fse.exists(deploymentTemplate)) {
const templateJson = await fse.readJson(deploymentTemplate);
const runtimeSettings = templateJson.moduleContent.$edgeAgent["properties.desired"].runtime.settings;
const registries = runtimeSettings.registryCredentials;
if (registries) {
await Utility.loadEnv(envFile);
const expanded = Utility.expandEnv(JSON.stringify(registries, null, 2));
const pattern: RegExp = new RegExp(/\$([a-zA-Z0-9_]+)|\${([a-zA-Z0-9_]+)}/g);
const matchArr = expanded.match(pattern);
if (matchArr && matchArr.length > 0) {
await this.askEditEnv(envFile);
try {
const folderPath = folder.uri.fsPath;
if (folder) {
const deploymentTemplate = path.join(folderPath, Constants.deploymentTemplate);
const envFile = path.join(folderPath, Constants.envFile);
if (await fse.exists(deploymentTemplate)) {
const templateJson = await fse.readJson(deploymentTemplate);
const runtimeSettings = templateJson.moduleContent.$edgeAgent["properties.desired"].runtime.settings;
const registries = runtimeSettings.registryCredentials;
if (registries) {
await Utility.loadEnv(envFile);
const expanded = Utility.expandEnv(JSON.stringify(registries, null, 2));
const pattern: RegExp = new RegExp(/\$([a-zA-Z0-9_]+)|\${([a-zA-Z0-9_]+)}/g);
const matchArr = expanded.match(pattern);
if (matchArr && matchArr.length > 0) {
await this.askEditEnv(envFile);
}
}
}
}
}
} catch (err) {}
}

// TODO: The command is temperory for migration stage, will be removed later.
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function activate(context: vscode.ExtensionContext) {

const folders = vscode.workspace.workspaceFolders;
if (folders && folders.length > 0) {
folders.forEach(async (value) => await edgeManager.checkRegistryEnv(value));
folders.forEach((value) => edgeManager.checkRegistryEnv(value));
}
}

Expand Down

0 comments on commit 62cf0f2

Please sign in to comment.