-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpreinstall.js
More file actions
37 lines (30 loc) · 964 Bytes
/
preinstall.js
File metadata and controls
37 lines (30 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/env node
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const commandExistsSync = require('command-exists').sync;
async function isFuncVm() {
let stdout;
try {
const { stdout } = await exec(`func --is-funcvm`);
return stdout.trim() === 'yes';
} catch {
return false;
}
}
async function validateEnvironment() {
try {
console.log('Validating environment...\n');
const funcExists = commandExistsSync('ls');
if (!funcExists) {
// we're good
process.exit(0);
}
const funcvmInstalled = await isFuncVm();
if (!funcvmInstalled) {
console.warn(`Azure Functions Core Tools appears to be installed already. It's highly recommended that you uninstall it before installing funcvm.`);
}
} catch (err) {
console.log(err);
}
}
validateEnvironment();