Skip to content
This repository was archived by the owner on Feb 11, 2020. It is now read-only.

Commit 6211d82

Browse files
author
Dr. Safi
committed
Update - using common configuration file for shellscript & base paths.
1 parent d256a8e commit 6211d82

File tree

1 file changed

+6
-8
lines changed
  • module/reusableNestedUnit/implementation/shellscript

1 file changed

+6
-8
lines changed

module/reusableNestedUnit/implementation/shellscript/Unit.class.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { classDecorator as prototypeChainDebug} from 'appscript/module/prototype
22
import { add, execute, applyMixin, conditional } from 'appscript/utilityFunction/decoratorUtility.js'
33
import { extendedSubclassPattern } from 'appscript/utilityFunction/extendedSubclassPattern.js'
44
import { curried as getTableDocumentCurried } from "appscript/utilityFunction/database/query/getTableDocument.query.js";
5-
import { exec, spawn, spawnSync } from 'child_process'
5+
import { exec, execSync, spawn, spawnSync } from 'child_process'
66

77
let getDocument = {
88
'Unit': getTableDocumentCurried({ documentId: 'shellscript_unit' })
@@ -27,6 +27,7 @@ export default ({ Superclass }) => {
2727
switch (this.implementation) {
2828
case 'spawn':
2929
try {
30+
console.log(this.appBasePath)
3031
console.log(message); console.log(`${this.command} ${this.argument}`)
3132
childProcess = spawnSync(this.command, this.argument, this.option)
3233
if(childProcess.status > 0) throw childProcess.error
@@ -46,21 +47,18 @@ export default ({ Superclass }) => {
4647
case 'file':
4748
try {
4849
console.log(message); console.log(`shellscript file: ${this.filename}`)
49-
let appBasePath = '/project/application/source/containerInstallationNodejs/shellScript/'
50-
this.option.cwd = appBasePath
51-
childProcess = spawnSync(`sh`, `${this.filename}`, this.option)
52-
if(childProcess.status > 0) throw childProcess.error
50+
this.option.cwd = this.shellscriptPath
51+
execSync(`sh ${this.filename}`, this.option)
5352
} catch (error) {
54-
let status = (childProcess) ? childProcess.status : 1;
55-
process.exit(status)
53+
process.exit(1)
5654
}
5755
break;
5856
default:
5957
console.log('shellscriptUnit.implementation does not match any option.')
6058
break;
6159
}
6260
// important to prevent 'unable to re-open stdin' error between shells.
63-
await new Promise(resolve => setTimeout(resolve, 1000)) // wait x seconds before next script execution.
61+
await new Promise(resolve => setTimeout(resolve, 500)) // wait x seconds before next script execution.
6462
}
6563
}
6664
return self

0 commit comments

Comments
 (0)