Fixed #284
This commit is contained in:
parent
6e04f93110
commit
d273d8f495
4 changed files with 28 additions and 15 deletions
5
index.ts
5
index.ts
|
|
@ -7,10 +7,9 @@ import update from './modules/module.updater';
|
|||
|
||||
(async () => {
|
||||
const cfg = yamlCfg.loadCfg();
|
||||
|
||||
const argv = appArgv(cfg.cli);
|
||||
|
||||
await update(argv.update);
|
||||
if (!argv.skipUpdate)
|
||||
await update(argv.update);
|
||||
|
||||
if (argv.all && argv.but) {
|
||||
console.log('[ERROR] --all and --but exclude each other!');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import yargs, { Choices } from 'yargs';
|
||||
import { args, AvailableMuxer, groups } from './module.args';
|
||||
|
||||
let argvC: { [x: string]: unknown; videoTitle: string, override: string[], fsRetryTime: number, forceMuxer: AvailableMuxer|undefined; username: string|undefined, password: string|undefined, silentAuth: boolean, skipSubMux: boolean, downloadArchive: boolean, addArchive: boolean, but: boolean, auth: boolean | undefined; dlFonts: boolean | undefined; search: string | undefined; 'search-type': string; page: number | undefined; 'search-locale': string; new: boolean | undefined; 'movie-listing': string | undefined; series: string | undefined; s: string | undefined; e: string | undefined; q: number; x: number; kstream: number; partsize: number; hslang: string; dlsubs: string[]; novids: boolean | undefined; noaudio: boolean | undefined; nosubs: boolean | undefined; dubLang: string[]; all: boolean; fontSize: number; allDubs: boolean; timeout: number; simul: boolean; mp4: boolean; skipmux: boolean | undefined; fileName: string; numbers: number; nosess: string; debug: boolean | undefined; nocleanup: boolean; help: boolean | undefined; service: 'funi' | 'crunchy'; update: boolean; fontName: string | undefined; _: (string | number)[]; $0: string; };
|
||||
let argvC: { [x: string]: unknown; skipUpdate: boolean, videoTitle: string, override: string[], fsRetryTime: number, forceMuxer: AvailableMuxer|undefined; username: string|undefined, password: string|undefined, silentAuth: boolean, skipSubMux: boolean, downloadArchive: boolean, addArchive: boolean, but: boolean, auth: boolean | undefined; dlFonts: boolean | undefined; search: string | undefined; 'search-type': string; page: number | undefined; 'search-locale': string; new: boolean | undefined; 'movie-listing': string | undefined; series: string | undefined; s: string | undefined; e: string | undefined; q: number; x: number; kstream: number; partsize: number; hslang: string; dlsubs: string[]; novids: boolean | undefined; noaudio: boolean | undefined; nosubs: boolean | undefined; dubLang: string[]; all: boolean; fontSize: number; allDubs: boolean; timeout: number; simul: boolean; mp4: boolean; skipmux: boolean | undefined; fileName: string; numbers: number; nosess: string; debug: boolean | undefined; nocleanup: boolean; help: boolean | undefined; service: 'funi' | 'crunchy'; update: boolean; fontName: string | undefined; _: (string | number)[]; $0: string; };
|
||||
|
||||
export type ArgvType = typeof argvC;
|
||||
|
||||
|
|
|
|||
|
|
@ -587,6 +587,18 @@ const args: TAppArg<boolean|number|string|unknown[]>[] = [
|
|||
service: 'both',
|
||||
type: 'string',
|
||||
usage: '${title}'
|
||||
},
|
||||
{
|
||||
name: 'skipUpdate',
|
||||
describe: 'If true, the tool won\'t check for updates',
|
||||
docDescribe: true,
|
||||
group: 'util',
|
||||
service: 'both',
|
||||
type: 'boolean',
|
||||
usage: '',
|
||||
default: {
|
||||
default: false
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ import { CompilerOptions, transpileModule } from 'typescript';
|
|||
import tsConfig from '../tsconfig.json';
|
||||
import fsextra from 'fs-extra';
|
||||
import seiHelper from 'sei-helper';
|
||||
const workingDir = (process as NodeJS.Process & {
|
||||
pkg?: unknown
|
||||
}).pkg ? path.dirname(process.execPath) : path.join(__dirname, '/..');
|
||||
import { workingDir } from './module.cfg-loader';
|
||||
const updateFilePlace = path.join(workingDir, 'config', 'updates.json');
|
||||
|
||||
const updateIgnore = [
|
||||
|
|
@ -44,7 +42,7 @@ export type ApplyItem = {
|
|||
export default (async (force = false) => {
|
||||
const isPackaged = (process as NodeJS.Process & {
|
||||
pkg?: unknown
|
||||
}).pkg ? true : false;
|
||||
}).pkg ? true : !!process.env.contentDirectory;
|
||||
if (isPackaged) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -91,13 +89,13 @@ export default (async (force = false) => {
|
|||
|
||||
const remove: string[] = [];
|
||||
|
||||
changedFiles.filter(a => a.status !== 'added').forEach(async a => {
|
||||
for (const a of changedFiles.filter(a => a.status !== 'added')) {
|
||||
if (!askBeforeUpdate.some(pattern => matchString(pattern, a.filename)))
|
||||
return;
|
||||
const answer = await seiHelper.question(`The developer decided that the file '${a.filename}' may contain information you changed yourself. Should they be overriden to be updated? [y/N]`);
|
||||
if (answer.toLowerCase() === 'y')
|
||||
remove.push(a.sha);
|
||||
});
|
||||
}
|
||||
|
||||
const changesToApply = await Promise.all(changedFiles.filter(a => !remove.includes(a.sha)).map(async (a): Promise<ApplyItem> => {
|
||||
if (a.filename.endsWith('.ts')) {
|
||||
|
|
@ -108,7 +106,7 @@ export default (async (force = false) => {
|
|||
}).outputText,
|
||||
type: a.status === 'modified' ? ApplyType.UPDATE : a.status === 'added' ? ApplyType.ADD : ApplyType.DELETE
|
||||
};
|
||||
console.log('✓ transpiled %s', ret.path);
|
||||
console.log('✓ Transpiled %s', ret.path);
|
||||
return ret;
|
||||
} else {
|
||||
const ret = {
|
||||
|
|
@ -116,15 +114,19 @@ export default (async (force = false) => {
|
|||
content: (await got(a.raw_url)).body,
|
||||
type: a.status === 'modified' ? ApplyType.UPDATE : a.status === 'added' ? ApplyType.ADD : ApplyType.DELETE
|
||||
};
|
||||
console.log('✓ transpiled %s', ret.path);
|
||||
console.log('✓ Got %s', ret.path);
|
||||
return ret;
|
||||
}
|
||||
}));
|
||||
|
||||
changesToApply.forEach(a => {
|
||||
fsextra.ensureDirSync(path.dirname(a.path));
|
||||
fs.writeFileSync(path.join(__dirname, '..', a.path), a.content);
|
||||
console.log('✓ written %s', a.path);
|
||||
try {
|
||||
fsextra.ensureDirSync(path.dirname(a.path));
|
||||
fs.writeFileSync(path.join(__dirname, '..', a.path), a.content);
|
||||
console.log('✓ Written %s', a.path);
|
||||
} catch (er) {
|
||||
console.log('✗ Error while writing %s', a.path)
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[INFO] Done');
|
||||
|
|
|
|||
Loading…
Reference in a new issue