-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiqeo_opal_loader.js
More file actions
33 lines (24 loc) · 870 Bytes
/
Copy pathiqeo_opal_loader.js
File metadata and controls
33 lines (24 loc) · 870 Bytes
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
29
30
31
32
const loaderUtils = require('loader-utils');
const exec = require('child_process').exec;
const path = require("path")
const glob = require("glob")
module.exports = function(source) {
const callback = this.async();
const options = loaderUtils.getOptions(this);
// paths for file dependencies to be watched paths
const dirs = options["watch_dirs"]
if ( dirs ) {
if ( !Array.isArray( dirs ) ) { dirs = [ dirs ] }
for ( let dir of dirs ) {
for ( let file of glob.sync(`${dir}/**/*`,{nodir:true}) ) {
this.addDependency(file)
}
}
}
cmd = "rake opal:webpack_build"
const max_buffer = options["max_buffer"] ? options["max_buffer"] : 10485760 // 10MiB default
exec(cmd, { maxBuffer: max_buffer }, function (error, stdout, stderr) {
if (error) { return callback(error, null); }
callback(null, stdout);
});
};