Skip to content

Commit ef22a3d

Browse files
author
Jay Nanduri
committed
Added logic to consider the executable packed inside the module
1 parent e89697c commit ef22a3d

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "ast-cli-javascript-wrapper",
33
"version": "1.0.0",
44
"description": "AST CLI Javascript wrapper",
5-
"main": "index.js",
5+
"main": "CxAuth.js",
6+
"files": ["src","cx.exe"],
67
"scripts": {
78
"test": "echo \"Error: no test specified\" && exit 1"
89
},

src/CxAuth.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
let spawn = require('child_process').spawn;
22
let CxScanConfig = require('./CxScanConfig.js');
33
let loc = "cx.exe ";
4+
let path = require('path');
45
let prc = null;
5-
let scanCreate = function(cxScanConfig) {
6+
7+
function scanCreate(cxScanConfig) {
68

79
if(cxScanConfig != null) {
810
var params = ['scan','create','-v','--format','json'];
@@ -30,9 +32,11 @@ let scanCreate = function(cxScanConfig) {
3032
params.push(cxScanConfig.paramMap.get(indKey));
3133
}
3234
}
33-
34-
prc = spawn(loc,params)
35-
//prc.stdout.setEncoding('utf8');
35+
let appRoot = path.resolve(__dirname);
36+
let newPath = appRoot.replace("src","cx.exe")
37+
console.log(newPath);
38+
prc = spawn(newPath,params)
39+
prc.stdout.setEncoding('utf8');
3640
prc.stdout.on('data', function (data) {
3741
var str = data.toString()
3842
var lines = str.split(/(\r?\n)/g);
@@ -42,12 +46,27 @@ let scanCreate = function(cxScanConfig) {
4246
prc.on('close', function (code) {
4347
console.log('process exit code ' + code);
4448
});
49+
50+
// spawn(newPath,params, (error, stdout, stderr) => {
51+
// if (error) {
52+
// console.error(`error: ${error.message}`);
53+
// return;
54+
// }
55+
//
56+
// if (stderr) {
57+
// console.error(`stderr: ${stderr}`);
58+
// return;
59+
// }
60+
//
61+
// console.log(`stdout:\n${stdout}`);
62+
// });
4563
}
4664
else {
4765
console.log("Pass the Cx Scan Config object");
4866
}
4967

5068
}
69+
module.exports = { scanCreate }
5170

5271
// let paramMap = new Map();
5372
// paramMap.set("--project-name","JSScanTest");

0 commit comments

Comments
 (0)