mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
修复 salsprep 不能正确被 webpack 打包的问题
This commit is contained in:
1 parent
c389d20c51
commit
cd6938dd6c
3 files changed
+15
-5
No files matched your search
@@ -1,4 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
formidable: () => {
|
||||
@@ -34,4 +35,17 @@ module.exports = {
|
||||
console.error('Cannot hack yargs');
|
||||
}
|
||||
},
|
||||
saslprep: () => {
|
||||
const q = require.resolve('saslprep');
|
||||
const mem = path.join(path.dirname(q), 'code-points.mem');
|
||||
const p = path.join(path.dirname(q), 'lib', 'memory-code-points.js');
|
||||
const data = fs.readFileSync(mem);
|
||||
const file = fs.readFileSync(p).toString().split('\n');
|
||||
if (file[7].includes('fs.readFileSync')) {
|
||||
file[7] = `const memory = Buffer.from('${data.toString('base64')}', 'base64');`;
|
||||
fs.writeFileSync(p, file.join('\n'));
|
||||
} else if (!file[7].includes('Buffer.from')) {
|
||||
console.error('Cannot hack saslprep');
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user