Skip to content

Commit

Permalink
Removed unneeded checkError Function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mocca101 committed Sep 5, 2023
1 parent d0245af commit 1494c10
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions deployment/generateStaticRelease.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
import childProcess from 'child_process';
import fs from 'fs';

function checkError (res) {
if (res && res.error) {
// abort if error
process.exit(1);
}
}

const repoPaths = [
'acdh-oeaw/OAD-Moving-Byzantium-Content',
'acdh-oeaw/OpenAtlas-Discovery-Content'
Expand All @@ -21,28 +14,28 @@ const tempBackupPath = 'temp_backup';
function backupContentAndConfig () {
if (!fs.existsSync(tempBackupPath)) {
console.log(`${tempBackupPath} folder does not exist, creating it`);
checkError(childProcess.execSync(`mkdir ${tempBackupPath}`));
childProcess.execSync(`mkdir ${tempBackupPath}`);
} else {
fs.readdirSync(tempBackupPath).forEach(f => fs.rmSync(`${tempBackupPath}/${f}`, { recursive: true }));
}

if (fs.existsSync('config/discoveryConfig.json')) {
checkError(fs.renameSync('config/discoveryConfig.json', `${tempBackupPath}/discoveryConfig.json`));
fs.renameSync('config/discoveryConfig.json', `${tempBackupPath}/discoveryConfig.json`);
}

checkError(fs.renameSync('content', `${tempBackupPath}/content`));
fs.renameSync('content', `${tempBackupPath}/content`);

checkError(fs.renameSync('public', `${tempBackupPath}/public`));
fs.renameSync('public', `${tempBackupPath}/public`);
}

function restoreContentAndConfig () {
if (fs.existsSync(`${tempBackupPath}/discoveryConfig.json`)) {
checkError(fs.renameSync(`${tempBackupPath}/discoveryConfig.json`, 'config/discoveryConfig.json'));
fs.renameSync(`${tempBackupPath}/discoveryConfig.json`, 'config/discoveryConfig.json');
}

checkError(fs.renameSync(`${tempBackupPath}/content`, 'content'));
fs.renameSync(`${tempBackupPath}/content`, 'content');

checkError(fs.renameSync(`${tempBackupPath}/public`, 'public'));
fs.renameSync(`${tempBackupPath}/public`, 'public');

fs.rmSync(tempBackupPath, { recursive: true });
}
Expand All @@ -64,15 +57,15 @@ function createRelease (repoPath) {

clearContentAndConfig();

checkError(childProcess.execSync(`node deployment/loadContent.mjs ${repoPath}`));
childProcess.execSync(`node deployment/loadContent.mjs ${repoPath}`);

// run npm run generate
console.log('Running npm run generate');
checkError(childProcess.execSync('npm run generate'));
childProcess.execSync('npm run generate');
console.log('npm run generate finished');

if (!fs.existsSync('releases')) {
checkError(fs.mkdirSync('releases'));
fs.mkdirSync('releases');
}
const currentGitTagVersion = childProcess.execSync('git describe --tags --abbrev=0').toString().trim();

Expand Down

0 comments on commit 1494c10

Please sign in to comment.