puppyperpetual 1.3.0 → 1.3.2

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "puppyperpetual",
3
3
  "type": "module",
4
4
  "types": "./src/index.d.ts",
5
- "version": "1.3.0",
5
+ "version": "1.3.2",
6
6
  "description": "Run stuff FOREVER! PERPETUALLY!",
7
7
  "main": "./src/index.js",
8
8
  "exports": {
@@ -175,8 +175,8 @@ export class ProcessManager {
175
175
  }
176
176
 
177
177
  async gitPull() {
178
- this.logger.logSend("Performing git pull...");
179
- this.executeCommand('git', ['pull'], 'ignore');
178
+ // this.logger.logSend("Performing git pull...");
179
+ await this.executeCommand('git', ['pull'], 'ignore');
180
180
  }
181
181
 
182
182
  async getGitHash() {
@@ -243,7 +243,7 @@ export class ProcessManager {
243
243
  await this.gitPull();
244
244
  }
245
245
  const newHash = await this.getGitHash();
246
- if (newHash && newHash !== this.currentHash && this.config.restart_on_update) {
246
+ if (newHash && newHash !== this.currentHash && this.options.restart_on_update) {
247
247
  this.logger.logSend(`Git hash changed from ${this.currentHash} to ${newHash}. Restarting process.`);
248
248
  this.currentHash = newHash;
249
249
  await this.startProcess();
@@ -252,21 +252,32 @@ export class ProcessManager {
252
252
  }
253
253
 
254
254
  executeCommand(command, args, stdio = "inherit") {
255
- let dir = this.options.dir || "";
255
+ const dir = this.options.dir || "";
256
256
 
257
257
  console.log(dir, this.options.dir);
258
258
 
259
- const cmdProcess = spawn(command, args, {
260
- stdio,
261
- cwd: this.options.dir && this.options.dir !== "" && dir,
262
- });
263
-
264
- cmdProcess.on('exit', (code) => {
265
- if (stdio !== 'ignore') console.log(`${command} exited with code: ${code}`);
266
- });
267
-
268
- cmdProcess.on('error', (err) => {
269
- console.error(`Failed to start ${command}:`, err);
259
+ return new Promise((resolve, reject) => {
260
+ const cmdProcess = spawn(command, args, {
261
+ stdio,
262
+ cwd: this.options.dir && this.options.dir !== "" ? dir : undefined,
263
+ });
264
+
265
+ cmdProcess.on("exit", (code) => {
266
+ if (stdio !== "ignore") {
267
+ console.log(`${command} exited with code: ${code}`);
268
+ }
269
+
270
+ if (code === 0) {
271
+ resolve(code);
272
+ } else {
273
+ reject(new Error(`${command} exited with code ${code}`));
274
+ }
275
+ });
276
+
277
+ cmdProcess.on("error", (err) => {
278
+ console.error(`Failed to start ${command}:`, err);
279
+ reject(err);
280
+ });
270
281
  });
271
282
  }
272
283
  }