Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ typings/
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down Expand Up @@ -107,3 +105,4 @@ dist
.DS_Store
settings.json
.vscode
config.bat
2 changes: 1 addition & 1 deletion src/constants.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions src/modules/frontendlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,23 @@ module.exports.runCommand = (commandKey) => {
let frontendLib = configObj.cli ? configObj.cli.frontendLibrary : undefined;

if(frontendLib && frontendLib.projectPath && frontendLib[commandKey]) {
return new Promise((resolve) => {
return new Promise((resolve,reject) => {
let projectPath = utils.trimPath(frontendLib.projectPath);
let cmd = frontendLib[commandKey];

utils.log(`Running ${commandKey}: ${cmd}...`);
const proc = spawnCommand(cmd, { stdio: 'inherit', cwd: projectPath });
proc.on('exit', (code) => {
utils.log(`frontendlib: ${commandKey} completed with exit code: ${code}`);
proc.on('error', (err) => {
utils.error(`frontendlib: ${commandKey} failed to start: ${err.message}`);
reject(err);
});
proc.on('exit', (code, signal) => {
if(code || signal) {
let reason = signal ? `terminated by signal: ${signal}` : `failed with exit code: ${code}`;
utils.error(`frontendlib: ${commandKey} ${reason}`);
return reject(new Error(`frontendlib: ${commandKey} ${reason}`));
}
Comment on lines 100 to +110
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest commit. Both frontendlib.js and hostproject.js now handle the signal argument in the exit handler and include a proc.on('error') handler to reject on spawn failures.

utils.log(`frontendlib: ${commandKey} completed successfully`);
resolve();
});
});
Expand Down
16 changes: 12 additions & 4 deletions src/modules/hostproject.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ module.exports.runCommand = async (commandKey) => {
let hostProject = configObj.cli ? configObj.cli.hostProject : undefined;

if(hostProject && hostProject.projectPath && hostProject[commandKey]) {
return new Promise((resolve) => {
return new Promise((resolve,reject) => {
let projectPath = utils.trimPath(hostProject.projectPath);
let cmd = hostProject[commandKey];

utils.log(`Running ${commandKey}: ${cmd}...`);

const proc = spawnCommand(cmd, { stdio: 'inherit', cwd: projectPath});
proc.on('exit', (code) => {
utils.log(`hostproject: ${commandKey} completed with exit code: ${code}`);
proc.on('error', (err) => {
utils.error(`hostproject: ${commandKey} failed to start: ${err.message}`);
reject(err);
});
proc.on('exit', (code, signal) => {
if(code || signal) {
let reason = signal ? `terminated by signal: ${signal}` : `failed with exit code: ${code}`;
utils.error(`hostproject: ${commandKey} ${reason}`);
return reject(new Error(`hostproject: ${commandKey} ${reason}`));
}
Comment on lines 20 to +30
utils.log(`hostproject: ${commandKey} completed successfully`);
resolve();
});
});
Expand Down