mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 14:57:22 +03:00
Extracted logic to determine app version from function to generate dist file
This commit is contained in:
parent
be50b24504
commit
f59e569e22
1 changed files with 9 additions and 10 deletions
|
@ -47,6 +47,7 @@ if (!checkRequiredFiles([ paths.appHtml, paths.appIndexJs ])) {
|
||||||
const argvSliceStart = 2;
|
const argvSliceStart = 2;
|
||||||
const argv = process.argv.slice(argvSliceStart);
|
const argv = process.argv.slice(argvSliceStart);
|
||||||
const writeStatsJson = argv.indexOf('--stats') !== -1;
|
const writeStatsJson = argv.indexOf('--stats') !== -1;
|
||||||
|
const { version, hasVersion } = getVersionFromArgs(argv);
|
||||||
|
|
||||||
// Generate configuration
|
// Generate configuration
|
||||||
const config = configFactory('production');
|
const config = configFactory('production');
|
||||||
|
@ -117,7 +118,7 @@ checkBrowsers(paths.appPath, isInteractive)
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(zipDist)
|
.then(() => hasVersion && zipDist(version))
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (err && err.message) {
|
if (err && err.message) {
|
||||||
console.log(err.message);
|
console.log(err.message);
|
||||||
|
@ -200,15 +201,7 @@ function copyPublicFolder() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function zipDist() {
|
function zipDist(version) {
|
||||||
const minArgsToContainVersion = 3;
|
|
||||||
|
|
||||||
// If no version was provided, do nothing
|
|
||||||
if (process.argv.length < minArgsToContainVersion) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [ , , version ] = process.argv;
|
|
||||||
const versionFileName = `./dist/shlink-web-client_${version}_dist.zip`;
|
const versionFileName = `./dist/shlink-web-client_${version}_dist.zip`;
|
||||||
|
|
||||||
console.log(chalk.cyan(`Generating dist file for version ${chalk.bold(version)}...`));
|
console.log(chalk.cyan(`Generating dist file for version ${chalk.bold(version)}...`));
|
||||||
|
@ -227,3 +220,9 @@ function zipDist() {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getVersionFromArgs(argv) {
|
||||||
|
const [ version ] = argv;
|
||||||
|
|
||||||
|
return { version, hasVersion: !!version };
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue