Skip to content

Commit

Permalink
Clean temp directory when creating asset pack
Browse files Browse the repository at this point in the history
  • Loading branch information
IntelOrca committed Oct 14, 2022
1 parent aa58f99 commit 962c610
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
artifacts/
out/
temp/
Binary file removed artifacts/opensound.zip
Binary file not shown.
13 changes: 8 additions & 5 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import fs from 'fs';
import fs, { rmdir } from 'fs';
import path from 'path';
import { spawn } from 'child_process';
import { platform } from 'os';
Expand All @@ -8,8 +8,6 @@ const verbose = process.argv.indexOf('--verbose') != -1;

async function main() {
await mkdir('out');
await mkdir('temp');

await createObject('openrct2.audio.additional');
await createAssetPack('openrct2.sound');
await createPackage();
Expand All @@ -27,9 +25,8 @@ async function createPackage() {
}

async function createObject(dir) {
await rm('temp');
await mkdir('temp');
const workDir = 'temp';
await rmmkdir(workDir);

const root = await readJsonFile(path.join(dir, 'object.json'));
console.log(`Creating ${root.id}`);
Expand All @@ -56,6 +53,7 @@ async function createObject(dir) {

async function createAssetPack(dir) {
const workDir = 'temp';
await rmmkdir(workDir);

const root = await readJsonFile(path.join(dir, 'openrct2.sound.json'));
console.log(`Creating ${root.id}`);
Expand Down Expand Up @@ -177,6 +175,11 @@ async function ensureDirectoryExists(filename) {
await mkdir(dirname);
}

async function rmmkdir(path) {
await rm(path);
await mkdir(path);
}

function mkdir(path) {
return new Promise((resolve, reject) => {
fs.access(path, error => {
Expand Down

0 comments on commit 962c610

Please sign in to comment.