refactord paths.ts

This commit is contained in:
2022-06-11 00:05:32 -05:00
parent 29b40b4e43
commit 83570d9535
14 changed files with 148 additions and 97 deletions

View File

@@ -26,20 +26,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLIArgs = void 0;
exports.AllPaths = exports.CLIArgs = void 0;
const fs_1 = require("fs");
const command_line_args_1 = __importDefault(require("command-line-args"));
const paths_1 = require("./paths");
const readmefile_1 = require("./readmefile");
const build_1 = __importDefault(require("./build"));
const Path = __importStar(require("path"));
const paths_1 = __importDefault(require("./paths"));
exports.CLIArgs = (0, command_line_args_1.default)([
{ name: 'watch', alias: 'w', type: Boolean, defaultValue: false },
{ name: 'minify', alias: 'm', type: Boolean, defaultValue: false },
{ name: 'prettier', alias: 'p', type: Boolean, defaultValue: false },
{ name: 'srccomment', alias: 's', type: Boolean, defaultValue: false },
{ name: 'help', alias: 'h', type: Boolean, defaultValue: false },
{ name: 'baseurl', alias: 'bu', type: String, defaultValue: '' },
{ name: 'remotebranch', alias: 'rb', type: String, defaultValue: 'main' },
{ name: 'scriptsdir', alias: 'sd', type: String, defaultValue: 'scripts' },
{ name: 'distdir', alias: 'dd', type: String, defaultValue: 'dist' },
{ name: 'help', alias: 'h', type: Boolean },
]);
exports.AllPaths = (0, paths_1.default)({
baseURL: exports.CLIArgs.baseurl || '',
remoteBranch: exports.CLIArgs.remotebranch || 'main',
scriptBase: exports.CLIArgs.scriptpath || 'scripts',
distBase: exports.CLIArgs.distpath || 'dist',
});
if (exports.CLIArgs.help) {
let command = '<command>';
if (process.argv.length > 0) {
@@ -77,12 +87,12 @@ if (!(0, fs_1.existsSync)('package.json') || !(0, fs_1.lstatSync)('package.json'
process.exit(1);
}
//delete compiled scripts
(0, fs_1.readdirSync)(paths_1.DistBase).forEach(file => (0, fs_1.unlinkSync)(`${paths_1.DistBase}/${file}`));
(0, fs_1.readdirSync)(exports.AllPaths.base.dist).forEach(file => (0, fs_1.unlinkSync)(`${exports.AllPaths.base.dist}/${file}`));
//compile scripts
let scripts = (0, fs_1.readdirSync)(paths_1.ScriptBase);
let scripts = (0, fs_1.readdirSync)(exports.AllPaths.base.script);
let scriptMeta = [];
for (let name of scripts) {
let path = (0, paths_1.ScriptPath)(name);
let path = exports.AllPaths.script(name);
if (!name.endsWith('_') &&
(0, fs_1.existsSync)(path.dir) &&
(0, fs_1.lstatSync)(path.dir).isDirectory() &&