cispacempt-v2 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +18 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "main": "src/index.js",
3
3
  "name": "cispacempt-v2",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "description": "Fast CI engine for CodespaceMPT with script stages and file system hooks",
6
6
  "author": "argentidev",
7
7
  "license": "MIT",
package/src/index.js CHANGED
@@ -89,8 +89,7 @@ const path = require("path"),
89
89
  module.exports = {
90
90
 
91
91
  parse: async function (ciScript, repoName, fileSystem, tmp = true) {
92
- const isLinux = os.platform() === "linux";
93
- const isRoot = process.getuid && process.getuid() === 0;
92
+ let errorIn = [];
94
93
  let finalResult = [];
95
94
  let timeTaken;
96
95
  let combinedExitCode = 0;
@@ -118,8 +117,23 @@ module.exports = {
118
117
 
119
118
  downloadFiles(fileSystem, tempDir);
120
119
 
120
+ const installCommands = {
121
+ "package.json": "npm install",
122
+ "requirements.txt": "pip install -r requirements.txt",
123
+ "go.mod": "go mod download",
124
+ "composer.json": "composer install",
125
+ "Gemfile": "bundle install",
126
+ "Pipfile": "pipenv install"
127
+ };
128
+
121
129
  await new Promise((resolve) => {
122
130
  (async function (commands, callback) {
131
+ for (const fileName of Object.keys(installCommands)) {
132
+ const foundKey = Object.keys(parseDirectoryToJson(tempDir)).find(key => key.includes(fileName));
133
+ if (foundKey && !commands.includes(installCommands[fileName])) {
134
+ commands.push(installCommands[fileName]);
135
+ }
136
+ }
123
137
  const results = [];
124
138
 
125
139
  for (const command of commands) {
@@ -148,7 +162,6 @@ module.exports = {
148
162
 
149
163
  if (results.at(-1).exitCode !== 0) break;
150
164
  }
151
-
152
165
  callback(results);
153
166
  extensionSystem.runPostExecution(stage.name, results); // <-- post execution hook
154
167
  resolve();
@@ -160,6 +173,7 @@ module.exports = {
160
173
  if (result.error) {
161
174
  output += `Error: ${result.error}\n`;
162
175
  output += `${result.stderr ? result.stderr : ''}\n`;
176
+ !errorIn.includes(stage.name) ? errorIn.push(stage.name) : null;
163
177
  } else {
164
178
  output += `${result.stdout ? result.stdout : ''}\n`;
165
179
  }
@@ -191,6 +205,7 @@ module.exports = {
191
205
  version: os.release(),
192
206
  arch: os.arch(),
193
207
  },
208
+ errorIn: errorIn.length > 0 ? errorIn : null,
194
209
  };
195
210
 
196
211
  cleanUpAndRespond(tempDir);