mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
t
This commit is contained in:
1 parent
9247b71b5f
commit
7d3bdc2dd1
4 files changed
+332
-353
No files matched your search
+23
-10
@@ -1,24 +1,37 @@
|
||||
const fs = require('fs');
|
||||
const { root } = require('./utils');
|
||||
|
||||
module.exports = {
|
||||
formidable: () => {
|
||||
const tasks = ['incoming_form', 'file', 'json_parser', 'querystring_parser'];
|
||||
for (const task of tasks) {
|
||||
let file = fs.readFileSync(root(`node_modules/formidable/lib/${task}.js`)).toString();
|
||||
if (file.startsWith('if (global.GENTLY) require = GENTLY.hijack(require);')) {
|
||||
file = file.split('\n');
|
||||
file[0] = '';
|
||||
file = file.join('\n');
|
||||
fs.writeFileSync(root(`node_modules/formidable/lib/${task}.js`), file);
|
||||
const p = require.resolve(`formidable/lib/${task}`);
|
||||
const file = fs.readFileSync(p).toString().split('\n');
|
||||
if (file[0].includes('if (global.GENTLY) require = GENTLY.hijack(require);')) {
|
||||
file[0] = '// Hacked';
|
||||
fs.writeFileSync(p, file.join('\n'));
|
||||
} else if (!file[0].includes('// Hacked')) {
|
||||
console.error('Cannot hack formidable', task);
|
||||
}
|
||||
}
|
||||
},
|
||||
sockjs: () => {
|
||||
const file = fs.readFileSync(root('node_modules/sockjs/lib/sockjs.js')).toString().split('\n');
|
||||
const p = require.resolve('sockjs/lib/sockjs.js');
|
||||
const file = fs.readFileSync(p).toString().split('\n');
|
||||
if (file[139].includes('this.app.log')) {
|
||||
file[139] = '';
|
||||
fs.writeFileSync(root('node_modules/sockjs/lib/sockjs.js'), file.join('\n'));
|
||||
file[139] = '// Hacked';
|
||||
fs.writeFileSync(p, file.join('\n'));
|
||||
} else if (!file[139].includes('// Hacked')) {
|
||||
console.error('Cannot hack sockjs');
|
||||
}
|
||||
},
|
||||
yargs: () => {
|
||||
const p = require.resolve('yargs');
|
||||
const file = fs.readFileSync(p).toString().split('\n');
|
||||
if (file[12].includes('const argv = yargs(processArgs, cwd, require)')) {
|
||||
file[12] = 'const argv = yargs(processArgs, cwd)';
|
||||
fs.writeFileSync(p, file.join('\n'));
|
||||
} else if (!file[12].includes('const argv = yargs(processArgs, cwd)')) {
|
||||
console.error('Cannot hack yargs');
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user