5 examples of 'check angular version cmd' in JavaScript

Every line of 'check angular version cmd' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
4export function checkVersion({
5 version,
6 versionLimit,
7 notify = []
8}) {
9 if (lt(version, versionLimit)) {
10 notify.forEach(errorLog);
11 process.exit(1);
12 }
13}
6function checkVersion({ version, versionLimit, notify = [] }) {
7 if (lt(normalizeVersion(version), normalizeVersion(versionLimit))) {
8 notify.forEach(errorLog);
9 return false;
10 }
11 return true;
12}
9function checkVersion() {
10 const result = spawnSync(getCommand(), ["--version"]);
11
12 if (result.error || result.status) {
13 throw new Error(result.error || result.stderr.toString());
14 }
15
16 const stdout = result.stdout.toString();
17 const match = /Swift version ([0-9]+\.[0-9]+(\.[0-9]+)?)/.exec(stdout);
18
19 if (!match) {
20 // eslint-disable-next-line no-console
21 console.error("Could not detect Swift version:", stdout);
22 throw new Error("Unsupported Swift version (required: >4.1): " + stdout);
23 }
24
25 const components = match[1].split(".");
26
27 if (components[0] === "4") {
28 if (components[1] < 2) {
29 throw new Error("Unsupported Swift version. Required: 4.2");
30 } else {
31 return;
32 }
33 } else if (components[0] < 4) {
34 throw new Error("Unsupported Swift version. Required: 4.2");
35 }
36
37 // eslint-disable-next-line no-console
38 console.error("Potentially unsupported Swift version. Use Swift 4.2");
39}
70async function checkVersion() {
71 const version = getVersion();
72 const hrTime = process.hrtime();
73 const ctime = hrTime[0] * 1000 + hrTime[1] / 1000000;
74 const ltime = settings.get('lastAccessTime');
75 const lastAccessVersion = getLastAccessVersion(ctime, ltime);
76 if (lastAccessVersion && (version == lastAccessVersion)) {
77 //version matched with cached version
78 return;
79 }
80
81 const pv = await latestVersion('@here/cli');
82 if (pv > version) {
83 console.log("herecli('" + version + "') is out of date. Latest version is " + pv + ". Use command 'npm install -g @here/cli' to update to the latest version");
84 process.exit(1);
85 }
86 // version matched with current version. We are up to date
87 settings.set('lastAccessVersion', pv);
88 settings.set('lastAccessTime', ctime);
89}
9function checkNpmVersion() {
10 return new Promise((resolve, reject) => {
11 // Get npm version
12 try {
13 // remove local node_modules\.bin dir from path
14 // or we potentially get a wrong npm version
15 const newEnv = Object.assign({}, process.env);
16 newEnv.PATH = (newEnv.PATH || newEnv.Path || newEnv.path)
17 .split(path.delimiter)
18 .filter(dir => {
19 dir = dir.toLowerCase();
20 return !(dir.indexOf('iobroker') > -1 && dir.indexOf(path.join('node_modules', '.bin')) > -1);
21 })
22 .join(path.delimiter);
23
24 let timer = setTimeout(() => {
25 timer = null;
26 reject('Timeout');
27 }, 10000);
28
29 child_process.exec('npm -v', {encoding: 'utf8', env: newEnv, windowsHide: true}, (error, stdout, _stderr) => {
30 if (timer) {
31 let npmVersion = stdout;
32 clearTimeout(timer);
33 timer = null;
34 npmVersion = npmVersion.trim();
35 console.log('NPM version: ' + npmVersion);
36
37 if (gte(npmVersion, '5.0.0') && lt(npmVersion, '5.7.1')) {
38 console.warn('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
39 console.warn('WARNING:');
40 console.warn('You are using an unsupported npm version!');
41 console.warn('This can lead to problems when installing further packages');
42 console.warn();
43 console.warn('Please use "npm install -g npm@4" to downgrade npm to 4.x or ');
44 console.warn('use "npm install -g npm@latest" to install a supported version of npm!');
45 console.warn('You need to make sure to repeat this step after installing an update to NodeJS and/or npm.');
46 console.warn('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
47 process.exit(25);
48 }
49 resolve(npmVersion);
50 }
51 });
52 } catch (e) {
53 reject(e);
54 }
55 });
56}

Related snippets