diff --git a/README.md b/README.md index 275cbf0..dfd4d87 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ **`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包不能保证最新代码,最新代码以仓库代码为准! diff --git a/main.js b/main.js index d53c45e..d20bb3a 100755 --- a/main.js +++ b/main.js @@ -51,7 +51,7 @@ const commandBuilder = { describe: '含有nsd, cd值的json文件', type: 'string', 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}`); return JSON.parse(fs.readFileSync(paths.resolve(input), 'utf8')); } @@ -76,7 +76,7 @@ const commandBuilder = { const commandHandler = (command, argv) => { 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.cd: ${ts.cd}`); if (argv.url) { @@ -123,7 +123,7 @@ module.exports = yargs describe: '拥有完整$_ts的json文件', type: 'string', 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; } }, diff --git a/package.json b/package.json index 64641ad..59ac1ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rs-reverse", - "version": "1.1.2", + "version": "1.1.3", "description": "瑞数算法逆向,website reverse engineering", "main": "main.js", "directories": { diff --git a/src/makeCode.js b/src/makeCode.js index 65d7e3f..000a648 100644 --- a/src/makeCode.js +++ b/src/makeCode.js @@ -17,7 +17,7 @@ module.exports = function (ts, immucfg) { { name: 'makecode_output_code', desc: '输出动态代码:', - text: code, + text: '// 该行标记来源,非动态代码生成: ' + JSON.stringify(ts) + '\n\n' + code, extend: 'js', }, immucfg ? { diff --git a/utils/paths.js b/utils/paths.js index 0fd195e..312dc6c 100644 --- a/utils/paths.js +++ b/utils/paths.js @@ -3,19 +3,19 @@ const fs = require('fs'); const appDirectory = (() => { // 返回项目根目录 - const plist = path.resolve(__dirname).split('/'); - while (!fs.existsSync(path.resolve(plist.join('/'), 'package.json'))) { + const plist = path.resolve(__dirname).split(path.sep); + while (!fs.existsSync(path.resolve(plist.join(path.sep), 'package.json'))) { plist.pop(); if (plist.length === 0) return false; } - return plist.join('/'); + return plist.join(path.sep); })(); const resolveApp = (...relativePath) => path.resolve(appDirectory, ...relativePath); module.exports = { basePath: resolveApp(''), modulePath: resolveApp('node_modules'), - binPath: resolveApp('node_modules/.bin/'), + binPath: resolveApp('node_modules', '.bin'), package: resolveApp('package.json'), resolve: resolveApp, srcPath: resolveApp('src'),