snyk-go-plugin
Advanced tools
Comparing version 1.5.1 to 1.5.2
109
lib/index.js
@@ -15,5 +15,5 @@ var fs = require('fs'); | ||
function inspect(root, targetFile, options) { | ||
function inspect(root, targetFile) { | ||
return Promise.all([ | ||
@@ -23,8 +23,8 @@ getMetaData(root, targetFile), | ||
]) | ||
.then(function (result) { | ||
return { | ||
plugin: result[0], | ||
package: result[1], | ||
}; | ||
}); | ||
.then(function (result) { | ||
return { | ||
plugin: result[0], | ||
package: result[1], | ||
}; | ||
}); | ||
} | ||
@@ -34,26 +34,26 @@ | ||
return subProcess.execute('go', ['version'], {cwd: root}) | ||
.then(function (output) { | ||
var runtime; | ||
versionMatch = /(go\d+\.?\d+?\.?\d*)/.exec(output); | ||
if (versionMatch) { | ||
runtime = versionMatch[0]; | ||
} | ||
.then(function (output) { | ||
var runtime; | ||
var versionMatch = /(go\d+\.?\d+?\.?\d*)/.exec(output); | ||
if (versionMatch) { | ||
runtime = versionMatch[0]; | ||
} | ||
return { | ||
name: 'snyk-go-plugin', | ||
runtime: runtime, | ||
targetFile: pathToPosix(targetFile), | ||
}; | ||
}); | ||
return { | ||
name: 'snyk-go-plugin', | ||
runtime: runtime, | ||
targetFile: pathToPosix(targetFile), | ||
}; | ||
}); | ||
} | ||
// Hack: | ||
// We're using Zeit assets feature in order to support Python and Go testing | ||
// We're using Zeit assets feature in order to support Python and Go testing | ||
// within a binary release. By doing "path.join(__dirname, 'PATH'), Zeit adds | ||
// PATH file auto to the assets. Sadly, Zeit doesn't support (as far as I | ||
// understand) adding a full folder as an asset, and this is why we're adding | ||
// the required files this way. In addition, Zeit doesn't support | ||
// the required files this way. In addition, Zeit doesn't support | ||
// path.resolve(), and this is why I'm using path.join() | ||
function createAssets(){ | ||
assets = []; | ||
var assets = []; | ||
assets.push(path.join(__dirname, '../gosrc/resolve-deps.go')); | ||
@@ -70,4 +70,3 @@ assets.push(path.join(__dirname, '../gosrc/resolver/pkg.go')); | ||
var dirPath = path.dirname(writeFilePath); | ||
if (!fs.existsSync(dirPath)) | ||
{ | ||
if (!fs.existsSync(dirPath)) { | ||
fs.mkdirSync(dirPath); | ||
@@ -82,4 +81,3 @@ } | ||
// Windows | ||
if (pathParts.length > 1) | ||
{ | ||
if (pathParts.length > 1) { | ||
return pathParts[1]; | ||
@@ -90,3 +88,3 @@ } | ||
pathParts = filePath.split('/gosrc/'); | ||
return pathParts[1]; | ||
return pathParts[1]; | ||
} | ||
@@ -96,10 +94,9 @@ | ||
createAssets().forEach(function(currentReadFilePath) { | ||
if (!fs.existsSync(currentReadFilePath)) | ||
{ | ||
if (!fs.existsSync(currentReadFilePath)) { | ||
throw new Error('The file `' + currentReadFilePath + '` is missing'); | ||
} | ||
var relFilePathToDumpDir = | ||
var relFilePathToDumpDir = | ||
getFilePathRelativeToDumpDir(currentReadFilePath); | ||
var writeFilePath = path.join(tempDirName, relFilePathToDumpDir); | ||
@@ -115,3 +112,3 @@ | ||
var tempDirObj; | ||
return new Promise(function (resolve, reject) { | ||
return new Promise(function (resolve) { | ||
config = parseConfig(root, targetFile); | ||
@@ -121,8 +118,8 @@ resolve(config); | ||
tempDirObj = tmp.dirSync({ | ||
unsafeCleanup: true | ||
unsafeCleanup: true, | ||
}); | ||
dumpAllResolveDepsFilesInTempDir(tempDirObj.name); | ||
var goResolveTool = | ||
var goResolveTool = | ||
path.join(tempDirObj.name, 'resolve-deps.go'); | ||
@@ -136,3 +133,3 @@ var ignorePkgsParam; | ||
['run', goResolveTool, ignorePkgsParam], | ||
{ cwd: root } | ||
{cwd: root} | ||
); | ||
@@ -160,3 +157,3 @@ }).then(function (graph) { | ||
graph.sources().forEach(function (nodeId) { | ||
if (nodeId != VIRTUAL_ROOT_NODE_ID) { | ||
if (nodeId !== VIRTUAL_ROOT_NODE_ID) { | ||
graph.setEdge(VIRTUAL_ROOT_NODE_ID, nodeId); | ||
@@ -212,8 +209,6 @@ } | ||
function getProjectRootFromTargetFile(targetFile) { | ||
var fname = path.basename(targetFile); | ||
var resolved = path.resolve(targetFile); | ||
var parts = resolved.split(path.sep); | ||
if (parts[parts.length - 1] == 'Gopkg.lock') { | ||
if (parts[parts.length - 1] === 'Gopkg.lock') { | ||
return path.dirname(resolved); | ||
@@ -223,4 +218,4 @@ } | ||
if ( | ||
parts[parts.length - 1] == 'vendor.json' && | ||
parts[parts.length - 2] == 'vendor') { | ||
parts[parts.length - 1] === 'vendor.json' && | ||
parts[parts.length - 2] === 'vendor') { | ||
return path.dirname(path.dirname(resolved)); | ||
@@ -233,8 +228,8 @@ } | ||
function recursivelyBuildPkgTree( | ||
graph, | ||
node, | ||
lockedVersions, | ||
projectRootPath, | ||
counts | ||
) { | ||
graph, | ||
node, | ||
lockedVersions, | ||
projectRootPath, | ||
counts | ||
) { | ||
@@ -327,3 +322,3 @@ var isRoot = (node.Name === VIRTUAL_ROOT_NODE_ID); | ||
function isProjSubpackage(pkgPath, projectRootPath) { | ||
if (pkgPath == projectRootPath) { | ||
if (pkgPath === projectRootPath) { | ||
return true; | ||
@@ -334,5 +329,5 @@ } | ||
root = | ||
(root[root.length - 1] == path.sep) ? root : (root + path.sep); | ||
(root[root.length - 1] === path.sep) ? root : (root + path.sep); | ||
if (pkgPath.indexOf(root) != 0) { | ||
if (pkgPath.indexOf(root) !== 0) { | ||
return false; | ||
@@ -387,3 +382,3 @@ } | ||
var name = | ||
(subpackageName == '.' ? | ||
(subpackageName === '.' ? | ||
proj.name : | ||
@@ -448,3 +443,3 @@ proj.name + '/' + subpackageName); | ||
ignores = gvJson.ignore || ''; | ||
var ignores = gvJson.ignore || ''; | ||
ignores.split(/\s/).filter(function (s) { | ||
@@ -451,0 +446,0 @@ // otherwise it's a build-tag rather than a pacakge |
@@ -5,3 +5,3 @@ var childProcess = require('child_process'); | ||
var spawnOptions = { shell: true }; | ||
var spawnOptions = {shell: true}; | ||
if (options && options.cwd) { | ||
@@ -16,4 +16,8 @@ spawnOptions.cwd = options.cwd; | ||
var proc = childProcess.spawn(command, args, spawnOptions); | ||
proc.stdout.on('data', function (data) { stdout = stdout + data; }); | ||
proc.stderr.on('data', function (data) { stderr = stderr + data; }); | ||
proc.stdout.on('data', function (data) { | ||
stdout = stdout + data; | ||
}); | ||
proc.stderr.on('data', function (data) { | ||
stderr = stderr + data; | ||
}); | ||
@@ -20,0 +24,0 @@ proc.on('close', function (code) { |
@@ -1,1 +0,34 @@ | ||
{"name":"snyk-go-plugin","description":"Snyk CLI Golang plugin","homepage":"https://github.com/snyk/snyk-go-plugin","repository":{"type":"git","url":"https://github.com/snyk/snyk-go-plugin"},"main":"lib/index.js","scripts":{"lint":"jscs ./lib ./test/*.js ./test/system/*.js -v","test-functional":"tap ./test/*.test.js","test-system":"tap --timeout=300 ./test/system/*.test.js","test":"npm run test-functional && npm run test-system","test-system-windows":"tap --timeout=300 ./test/system/*.test.js -g \"^(?!.*prometheus)\"","test-windows":"npm run test-functional && npm run test-system-windows","semantic-release":"semantic-release pre && npm publish && semantic-release post","watch":"nodemon -e 'js go' -x 'npm run test-functional'"},"author":"snyk.io","license":"Apache-2.0","dependencies":{"graphlib":"^2.1.1","toml":"^2.3.2","tmp":"0.0.33"},"devDependencies":{"jscs":"^3.0.7","semantic-release":"^8.2.3","tap":"^10.7.0","tap-only":"0.0.5"},"version":"1.5.1"} | ||
{ | ||
"name": "snyk-go-plugin", | ||
"description": "Snyk CLI Golang plugin", | ||
"homepage": "https://github.com/snyk/snyk-go-plugin", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/snyk/snyk-go-plugin" | ||
}, | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"lint": "eslint -c .eslintrc lib test/*.js test/system/*.js", | ||
"test-functional": "tap ./test/*.test.js -R spec", | ||
"test-system": "tap -R spec --timeout=300 ./test/system/*.test.js", | ||
"test": "npm run test-functional && npm run test-system", | ||
"test-system-windows": "tap -R spec --timeout=300 ./test/system/*.test.js -g \"^(?!.*prometheus)\"", | ||
"test-windows": "npm run test-functional && npm run test-system-windows", | ||
"semantic-release": "semantic-release", | ||
"watch": "nodemon -e 'js go' -x 'npm run test-functional'" | ||
}, | ||
"author": "snyk.io", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"graphlib": "^2.1.1", | ||
"toml": "^2.3.2", | ||
"tmp": "0.0.33" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^4.11.0", | ||
"semantic-release": "^15", | ||
"tap": "^12.0.1", | ||
"tap-only": "0.0.5" | ||
}, | ||
"version": "1.5.2" | ||
} |
Sorry, the diff of this file is not supported yet
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
36035
15