fix: use path.sep

This commit is contained in:
rnet 2024-01-04 15:11:03 +08:00
parent cb08efe0f1
commit ccbcbcc3fa
5 changed files with 10 additions and 10 deletions

View File

@ -24,7 +24,7 @@
**`npx rs-reverse *`与在当前目录下运行`node main.js *`相对应** **`npx rs-reverse *`与在当前目录下运行`node main.js *`相对应**
如npx运行的包不是最新的可以加上-p参数后执行如`npx -p rs-reverse@latest rs-reverse makecookie`,非官方源可能存在版本不同步问题。 如npx运行的包不是最新的可以加上-p参数后执行如`npx -p rs-reverse@latest rs-reverse makecookie`,非官方源可能存在版本不同步问题,建议拉取时使用官方源:`--registry=https://registry.npmjs.org`
npm包不能保证最新代码最新代码以仓库代码为准! npm包不能保证最新代码最新代码以仓库代码为准!

View File

@ -51,7 +51,7 @@ const commandBuilder = {
describe: '含有nsd, cd值的json文件', describe: '含有nsd, cd值的json文件',
type: 'string', type: 'string',
coerce: (input) => { coerce: (input) => {
if (['1', '2'].includes(input)) input = paths.exampleResolve(`codes/${input}-\$_ts.json`); if (['1', '2'].includes(input)) input = paths.exampleResolve('codes', `${input}-\$_ts.json`);
if (!fs.existsSync(input)) throw new Error(`输入文件不存在: ${input}`); if (!fs.existsSync(input)) throw new Error(`输入文件不存在: ${input}`);
return JSON.parse(fs.readFileSync(paths.resolve(input), 'utf8')); return JSON.parse(fs.readFileSync(paths.resolve(input), 'utf8'));
} }
@ -76,7 +76,7 @@ const commandBuilder = {
const commandHandler = (command, argv) => { const commandHandler = (command, argv) => {
debugLog(argv.level); debugLog(argv.level);
const ts = argv.url?.$_ts || argv.file || require(paths.exampleResolve('codes/1-\$_ts.json')); const ts = argv.url?.$_ts || argv.file || require(paths.exampleResolve('codes', '1-\$_ts.json'));
logger.trace(`传入的$_ts.nsd: ${ts.nsd}`); logger.trace(`传入的$_ts.nsd: ${ts.nsd}`);
logger.trace(`传入的$_ts.cd: ${ts.cd}`); logger.trace(`传入的$_ts.cd: ${ts.cd}`);
if (argv.url) { if (argv.url) {
@ -123,7 +123,7 @@ module.exports = yargs
describe: '拥有完整$_ts的json文件', describe: '拥有完整$_ts的json文件',
type: 'string', type: 'string',
coerce: (input) => { coerce: (input) => {
if (['1', '2'].includes(input)) return paths.exampleResolve(`codes/${input}-\$_ts-full.json`); if (['1', '2'].includes(input)) return paths.exampleResolve('codes', `${input}-\$_ts-full.json`);
return input; return input;
} }
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "rs-reverse", "name": "rs-reverse",
"version": "1.1.2", "version": "1.1.3",
"description": "瑞数算法逆向,website reverse engineering", "description": "瑞数算法逆向,website reverse engineering",
"main": "main.js", "main": "main.js",
"directories": { "directories": {

View File

@ -17,7 +17,7 @@ module.exports = function (ts, immucfg) {
{ {
name: 'makecode_output_code', name: 'makecode_output_code',
desc: '输出动态代码:', desc: '输出动态代码:',
text: code, text: '// 该行标记来源,非动态代码生成: ' + JSON.stringify(ts) + '\n\n' + code,
extend: 'js', extend: 'js',
}, },
immucfg ? { immucfg ? {

View File

@ -3,19 +3,19 @@ const fs = require('fs');
const appDirectory = (() => { const appDirectory = (() => {
// 返回项目根目录 // 返回项目根目录
const plist = path.resolve(__dirname).split('/'); const plist = path.resolve(__dirname).split(path.sep);
while (!fs.existsSync(path.resolve(plist.join('/'), 'package.json'))) { while (!fs.existsSync(path.resolve(plist.join(path.sep), 'package.json'))) {
plist.pop(); plist.pop();
if (plist.length === 0) return false; if (plist.length === 0) return false;
} }
return plist.join('/'); return plist.join(path.sep);
})(); })();
const resolveApp = (...relativePath) => path.resolve(appDirectory, ...relativePath); const resolveApp = (...relativePath) => path.resolve(appDirectory, ...relativePath);
module.exports = { module.exports = {
basePath: resolveApp(''), basePath: resolveApp(''),
modulePath: resolveApp('node_modules'), modulePath: resolveApp('node_modules'),
binPath: resolveApp('node_modules/.bin/'), binPath: resolveApp('node_modules', '.bin'),
package: resolveApp('package.json'), package: resolveApp('package.json'),
resolve: resolveApp, resolve: resolveApp,
srcPath: resolveApp('src'), srcPath: resolveApp('src'),