Changed spawn to exec
This commit is contained in:
21
src/index.ts
21
src/index.ts
@@ -1,8 +1,9 @@
|
|||||||
import express, {Application, ErrorRequestHandler, Request, Response} from 'express'
|
import express, {Application, ErrorRequestHandler, Request, Response} from 'express'
|
||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
import * as env from 'env-var'
|
import * as env from 'env-var'
|
||||||
import {PushWebhook} from "./PushWebhook";
|
import { PushWebhook } from "./PushWebhook";
|
||||||
import {spawn} from "child_process";
|
import { exec } from "child_process";
|
||||||
|
import { promisify } from "util";
|
||||||
|
|
||||||
const app: Application = express()
|
const app: Application = express()
|
||||||
|
|
||||||
@@ -23,19 +24,17 @@ async function parsePushHook(webhook: PushWebhook) {
|
|||||||
clearTimeout(timeouts[repository])
|
clearTimeout(timeouts[repository])
|
||||||
timeouts[repository] = setTimeout(async () => {
|
timeouts[repository] = setTimeout(async () => {
|
||||||
delete timeouts[repository]
|
delete timeouts[repository]
|
||||||
const filename = repository
|
const safeFilename = repository
|
||||||
.replace(/[^\w\s/]/gi, '-')
|
.replace(/[^\w\s/]/gi, '-')
|
||||||
.replace(/\//gi, '_')
|
.replace(/\//gi, '_')
|
||||||
|
const safeTag = tag
|
||||||
|
.replace(/[^a-z0-9-]/gi, '')
|
||||||
|
const safeResourceUri = tag
|
||||||
|
.replace(/[^a-z0-9-./:]/gi, '')
|
||||||
try {
|
try {
|
||||||
const cp = spawn(`./${filename}.sh`, [tag, resource_url], {
|
await promisify(exec)(`./${safeFilename}.sh ${safeTag} ${safeResourceUri}`, {
|
||||||
cwd: rootDir,
|
cwd: rootDir
|
||||||
stdio: ['inherit', 'inherit', 'inherit', 'ipc']
|
|
||||||
});
|
});
|
||||||
cp.on('message', data => console.log(data))
|
|
||||||
await new Promise((resolve, reject) => {
|
|
||||||
cp.on('close', resolve)
|
|
||||||
cp.on('error', reject)
|
|
||||||
})
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user