daggerheart/tools/create-symlink.mjs
Murilo Brito 41181f19f1
new style for dialog roll and remove console.log debuggers (#272)
* new style for dialog roll and remove console.log debuggers

* enhance advantage logic
2025-07-05 14:34:42 -03:00

45 lines
1.2 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import readline from 'readline';
const askQuestion = question => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
return new Promise(resolve =>
rl.question(question, answer => {
rl.close();
resolve(answer);
})
);
};
const installPath = await askQuestion('Enter your Foundry install path: ');
// Determine if it's an Electron install (nested structure)
const nested = fs.existsSync(path.join(installPath, 'resources', 'app'));
const fileRoot = nested ? path.join(installPath, 'resources', 'app') : installPath;
try {
await fs.promises.mkdir('foundry');
} catch (e) {
if (e.code !== 'EEXIST') throw e;
}
// JavaScript files
for (const p of ['client', 'common', 'tsconfig.json']) {
try {
await fs.promises.symlink(path.join(fileRoot, p), path.join('foundry', p));
} catch (e) {
if (e.code !== 'EEXIST') throw e;
}
}
// Language files
try {
await fs.promises.symlink(path.join(fileRoot, 'public', 'lang'), path.join('foundry', 'lang'));
} catch (e) {
if (e.code !== 'EEXIST') throw e;
}