forked from laurent22/joplin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tools: Add repeat mechanism when electron-builder randomly fails to b…
…uild
- Loading branch information
Showing
6 changed files
with
56 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const execCommand = require('./execCommand'); | ||
|
||
async function main() { | ||
process.chdir(`${__dirname}/..`); | ||
|
||
const maxTries = 3; | ||
|
||
for (let i = 0; i < maxTries; i++) { | ||
try { | ||
console.info(await execCommand(['yarn', 'run', 'electron-builder'].join(' '))); | ||
console.info('electronBuilder: electron-builder completed successfully'); | ||
break; | ||
} catch (error) { | ||
console.info(error.stdout); | ||
console.error(error); | ||
|
||
if (error.stdout.includes('cannot resolve') && i !== maxTries - 1) { | ||
console.info(`electronBuilder: electron-builder could not download an asset - trying again (${i + 1})`); | ||
continue; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = main; |
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,22 @@ | ||
const execCommand = (command) => { | ||
const exec = require('child_process').exec; | ||
|
||
console.info(`Running: ${command}`); | ||
|
||
return new Promise((resolve, reject) => { | ||
exec(command, (error, stdout) => { | ||
if (error) { | ||
if (error.signal === 'SIGTERM') { | ||
resolve('Process was killed'); | ||
} else { | ||
error.stdout = stdout; | ||
reject(error); | ||
} | ||
} else { | ||
resolve(stdout.trim()); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = execCommand; |
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