snyk-go-plugin
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -12,8 +12,19 @@ var fs = require('fs'); | ||
function inspect(root, targetFile, options) { | ||
if (!options) { options = { dev: false }; } | ||
return Promise.all([ | ||
getMetaData(root), | ||
getDependencies(root, targetFile), | ||
]) | ||
.then(function (result) { | ||
return { | ||
plugin: result[0], | ||
package: result[1], | ||
}; | ||
}); | ||
} | ||
function getDependencies(root, targetFile) { | ||
var depLocks; | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
depLocks = parseDepLock(root, targetFile, options); | ||
depLocks = parseDepLock(root, targetFile); | ||
resolve(depLocks); | ||
@@ -38,9 +49,3 @@ } catch (e) { | ||
return { | ||
plugin: { | ||
name: 'snyk-go-plugin', | ||
// TODO: engine: `go version` | ||
}, | ||
package: pkgsTree, | ||
} | ||
return pkgsTree; | ||
}).catch(function (error) { | ||
@@ -57,3 +62,13 @@ if (typeof error === 'string') { | ||
function isInternalPkg(pkgPath, projectRootPath) { | ||
function getMetaData(root) { | ||
return subProcess.execute('go', ['version'], {cwd: root}) | ||
.then(function (output) { | ||
return { | ||
name: 'snyk-go-plugin', | ||
runtime: /(go\d+\.\d+\.\d+)/.exec(output)[0], | ||
}; | ||
}); | ||
} | ||
function isRootSubpkg(pkgPath, projectRootPath) { | ||
if (pkgPath == projectRootPath) { | ||
@@ -90,7 +105,7 @@ return true; | ||
if (isRoot || isInternalPkg(goDepsTree.Dir, projectRootPath)) { | ||
if (isRoot || isRootSubpkg(goDepsTree.Dir, projectRootPath)) { | ||
pkg.version = '0.0.0'; | ||
} else if (!depLocks[pkg.name]) { | ||
pkg.version = ''; | ||
// TODO: throw or warn here | ||
// TODO: warn or set to "?" ? | ||
} else { | ||
@@ -111,3 +126,3 @@ pkg.version = depLocks[pkg.name].version; | ||
function parseDepLock(root, targetFile, options) { | ||
function parseDepLock(root, targetFile) { | ||
var lock = fs.readFileSync(path.join(root, targetFile)); | ||
@@ -137,2 +152,2 @@ | ||
return deps; | ||
} | ||
} |
@@ -28,3 +28,3 @@ { | ||
}, | ||
"version": "1.1.4" | ||
"version": "1.2.0" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11870
139