-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add support for projectRunner * fix: passed test cases * refactor: Improve bundler.js logic for handling projectRunner apps * feat: support projectPath Config in projectRunner * Update .gitignore --------- Co-authored-by: Shalitha Suranga <shalithasuranga@gmail.com>
- Loading branch information
1 parent
271e535
commit 5827fca
Showing
5 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const process = require('process'); | ||
const spawnCommand = require('spawn-command'); | ||
const config = require('./config'); | ||
const utils = require('../utils'); | ||
|
||
module.exports.containsRunnerApp = () => { | ||
let configObj = config.get(); | ||
return !!(configObj.cli && configObj.cli.projectRunner); | ||
} | ||
|
||
module.exports.runCommand = async (commandKey) => { | ||
let configObj = config.get(); | ||
let projectRunner = configObj.cli ? configObj.cli.projectRunner : undefined; | ||
|
||
if (projectRunner && projectRunner.projectPath && projectRunner[commandKey]) { | ||
|
||
return new Promise((resolve, _reject) => { | ||
let projectPath = utils.trimPath(projectRunner.projectPath); | ||
let cmd = projectRunner[commandKey]; | ||
|
||
utils.log(`Running ${commandKey}: ${cmd}...`); | ||
|
||
const proc = spawnCommand(cmd, { stdio: 'inherit', cwd: projectPath}); | ||
proc.on('exit', (code) => { | ||
utils.log(`Project Runner: ${commandKey} completed with exit code: ${code}`); | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports.runApp = async () => { | ||
let configObj = config.get(); | ||
let projectRunner = configObj.cli ? configObj.cli.projectRunner : undefined; | ||
|
||
if (projectRunner && projectRunner.projectPath && projectRunner.devCommand) { | ||
return new Promise((resolve, _reject) => { | ||
let projectPath = utils.trimPath(projectRunner.projectPath); | ||
let cmd = projectRunner.devCommand; | ||
|
||
utils.log(`Running Project Runner: ${cmd} ...`); | ||
const proc = spawnCommand(cmd, { stdio: 'inherit', cwd: projectPath}); | ||
proc.on('exit', (code) => { | ||
utils.log(`Project stopped with exit code: ${code}`); | ||
resolve(); | ||
}); | ||
}); | ||
} else { | ||
utils.error("Config file does not contain projectRunner.devCommand to run the project!!!"); | ||
process.exit(1); | ||
} | ||
} |