-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack-poppler.js
28 lines (23 loc) · 983 Bytes
/
webpack-poppler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const fs = require('fs')
const spawnSync = require('child_process').spawnSync;
function WebpackPoppler(options) {
this.options = options || {};
}
WebpackPoppler.prototype.apply = function (compiler) {
compiler.hooks.done.tap('WebpackPoppler', () => {
const permissions = this.options.permissions || '755';
spawnSync('mv', [`${compiler.outputPath}/poppler/bin/share`, `${compiler.outputPath}/share`]);
spawnSync('mv', [`${compiler.outputPath}/poppler/bin/lib`, `${compiler.outputPath}/lib`]);
spawnSync('mv', [`${compiler.outputPath}/poppler/bin`, `${compiler.outputPath}/bin`]);
const binPath = `${compiler.outputPath}/bin`;
fs.readdir(binPath, (err, items) => {
if (items && items.length > 0) {
for (let i = 0; i < items.length; i += 1) {
fs.chmodSync(`${binPath}/${items[i]}`, permissions);
}
}
});
fs.chmodSync(`${compiler.outputPath}/index.sh`, permissions);
});
};
module.exports = WebpackPoppler