Every line of 'how to find angular version in project' 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.
102 function findWebpackVersion(file) { 103 const fileInfo = fs.statSync(file); 104 105 let directory; 106 if (fileInfo.isFile()) { 107 const { name } = path.parse(file); 108 if (name !== 'index') { 109 return null; 110 } 111 112 directory = path.dirname(file); 113 } else if (fileInfo.isDirectory()) { 114 directory = file; 115 } else { 116 return null; 117 } 118 119 const webpackVersion = path.join(directory, 'webpack.js'); 120 121 try { 122 const fileStat = fs.statSync(webpackVersion); 123 return fileStat.isFile() ? webpackVersion : null; 124 } catch (e) { 125 return null; 126 } 127 }
28 export function guessAngularVersion(templateSrc: string): ITemplateVersionResult { 29 const allAttributes = new Set(); 30 const parsed = parse5.parse(templateSrc) as AST.Default.Document; 31 32 mapElementNodes(parsed, (element) => { 33 if (element.attrs) { 34 element.attrs.map((attr) => attr.name) 35 .forEach((attr) => allAttributes.add(attr)); 36 } 37 return element; 38 }); 39 40 const angular = angularDirectives.some((directive) => allAttributes.has(directive.toLowerCase())); 41 const angularJs = angularJsDirectives.some((directive) => allAttributes.has(directive.toLowerCase())); 42 if (angular && angularJs) { 43 return 'both'; 44 } 45 if (angular) { 46 return 'angular'; 47 } 48 if (angularJs) { 49 return 'angularjs'; 50 } 51 return 'unknown'; 52 }
208 function getModuleVersion(moduleName) { 209 if (moduleName == null) return null; 210 211 moduleName += ''; 212 213 var mdNames = moduleName.split('/'), mdName, v; 214 215 do { 216 mdName = getModuleNameByUrl(mdNames.join('/')); 217 mdNames = mdNames.slice(0, -1); 218 v = Versions[mdName]; 219 } while ( 220 mdNames.length && v == null 221 ) 222 223 return v; 224 }
160 static async getModuleVersion(name: string): Promise { 161 const path = process.cwd() + '/node_modules/' + name + '/package.json'; 162 163 if (await pathExists(path)) { 164 const pkg = require(path); 165 return chalk.green(pkg.version); 166 } 167 168 return chalk.red('not-found'); 169 }
75 function getVersion(module){ 76 var version = packageConfig(module); 77 try { 78 version = getHaxeDependencies()[module]; 79 } catch (error){ 80 console.warn('using default '+ module +' version'); 81 } 82 if(version == undefined){ 83 version = localConfig.haxeDependencies[module]; 84 } 85 return version; 86 }
1 function getPkgVersion(path) { 2 return require(path).version; 3 }
113 lookupPackageVersion(path, versionSpecified) { 114 if (fileExists(path)) { 115 const pkg = readFile(path); 116 let version = null; 117 try { 118 const pkgContent = JSON.parse(pkg); 119 version = pkgContent.version || null; 120 if (isTarGz(versionSpecified)) { 121 version = pkgContent._from || unknownVersion; 122 if (version.includes('@')) { 123 // use the bit after the '@' 124 version = version.split('@')[1] 125 } 126 } 127 } catch(e) { 128 // JSON parse error 129 } 130 return version; 131 } else { 132 return null; 133 } 134 }
67 function guessPreviousBranch(version) { 68 const result = version.match(/(\d+)\.(\d+)\.(\d+)/); 69 const major = parseInt(result[1], 10); 70 const minor = parseInt(result[2], 10); 71 const patch = parseInt(result[3], 10); 72 if (patch === 0) { 73 // new major or minor version... 74 75 // new minor version 76 if (minor !== 0) { // if 8.1.0, 6.5.0, 7.8.0, etc 77 // return previous minor version's maintenance branch 78 return `${major}_${minor - 1}_X`; // return 8_0_X, 6_4_X, 7_7_X respectively 79 } 80 81 // major version 82 // try and find latest maintenance branch of previous major version by asking for git branches with a pattern 83 const output = execSync(`git branch --list ${major - 1}_*_X`, { encoding: 'utf8' }); 84 const lines = output.split(/\r?\n/).map(l => l.trim()).filter(l => l).sort(); 85 const latestBranch = lines[lines.length - 1]; 86 return latestBranch; 87 } 88 89 // e.g. 8.2.1, 1.2.3, 7.5.2 90 return `${major}_${minor}_${patch - 1}_GA`; // try 8_2_0, 1_2_2, 7_5_1? 91 // Maybe we can try and confirm the tag actually exists? Because we've been awful about tagging and tag names... 92 // ideally it should be like "v1.2.3", but we're doing like '8_1_1_GA' so far 93 }
16 function ver(name) { 17 18 if (appData.dependencies != null && appData.dependencies[name]) { 19 return appData.dependencies[name]; 20 } 21 22 return '0.0.0'; 23 }
458 function getDependencyVersion(project, pkgName) { 459 if (pkgName === '/') { 460 return project.pkgJson.version; 461 } 462 463 try { 464 const pkgJsonPath = resolve.sync(`${pkgName}/package.json`, { 465 basedir: project.dir.asNative, 466 }); 467 468 const pkgJson = readJsonSync(pkgJsonPath); 469 470 const {version} = pkgJson; 471 472 return version; 473 } catch (err) { 474 return undefined; 475 } 476 }