mirror of
https://github.com/jsrozner/obsidian-tab-shifter.git
synced 2026-07-22 09:30:32 +00:00
Dev tools - touch .hotreload if in dev mode Env functionality (fix) - generate a file that holds the env constants since env is not available when run in obsidian - added file to do the static generation Other - add HISTORY - update obsidian instructions - minor README update
32 lines
1,018 B
JavaScript
32 lines
1,018 B
JavaScript
/*
|
|
Automatically copy files from build into a dev obsidian directory.
|
|
Pair this with the hot reload community plugin during development.
|
|
*/
|
|
|
|
// todo: consider typescript
|
|
|
|
require('dotenv').config();
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { execSync } = require('child_process');
|
|
|
|
|
|
const targetDir = (() => {
|
|
const manifest = JSON.parse(fs.readFileSync('manifest.json', 'utf8'));
|
|
const extId = manifest.id;
|
|
const obsPluginsDir = process.env.DEV_OBS_TGT_PLUGIN_DIR;
|
|
if (!extId || ! obsPluginsDir) {
|
|
return null;
|
|
}
|
|
return path.join(obsPluginsDir, extId);
|
|
})();
|
|
|
|
if (!targetDir || !fs.existsSync(targetDir)) {
|
|
console.error(`No id in manifest or unable to read the tgt plugin directory from env or ${targetDir} does not exist. Check env file`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`Copying from ./build to ${targetDir}`);
|
|
execSync(`cp -r ./build/* ${targetDir}`, { stdio: 'inherit' });
|
|
// Makes hotreload extension know to run
|
|
execSync(`touch ${targetDir}/.hotreload`, { stdio: 'inherit' });
|