|
@@ -5,6 +5,7 @@
|
|
var exec = require('child_process').exec;
|
|
var exec = require('child_process').exec;
|
|
var path = require('path');
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
var fs = require('fs');
|
|
|
|
+var uuid = require('uuid');
|
|
var webRoot = path.dirname(path.dirname(__dirname));
|
|
var webRoot = path.dirname(path.dirname(__dirname));
|
|
var uppyRoot = path.dirname(webRoot);
|
|
var uppyRoot = path.dirname(webRoot);
|
|
var browserifyScript = webRoot + '/build-examples.js'
|
|
var browserifyScript = webRoot + '/build-examples.js'
|
|
@@ -20,6 +21,7 @@ hexo.extend.renderer.register('es6', 'js', function(data, options, callback) {
|
|
}
|
|
}
|
|
|
|
|
|
var slug = data.path.replace(/[^a-zA-Z0-9\_\.]/g, '-');
|
|
var slug = data.path.replace(/[^a-zA-Z0-9\_\.]/g, '-');
|
|
|
|
+ var slug = uuid.v4();
|
|
var dstPath = '/tmp/' + slug + '.js';
|
|
var dstPath = '/tmp/' + slug + '.js';
|
|
var cmd = 'node ' + browserifyScript + ' ' + data.path + ' ' + dstPath + ' --colors';
|
|
var cmd = 'node ' + browserifyScript + ' ' + data.path + ' ' + dstPath + ' --colors';
|
|
// hexo.log.i('hexo-renderer-uppyexamples: change detected in examples. running: ' + cmd);
|
|
// hexo.log.i('hexo-renderer-uppyexamples: change detected in examples. running: ' + cmd);
|
|
@@ -30,13 +32,24 @@ hexo.extend.renderer.register('es6', 'js', function(data, options, callback) {
|
|
|
|
|
|
hexo.log.i('hexo-renderer-uppyexamples: ' + stdout.trim());
|
|
hexo.log.i('hexo-renderer-uppyexamples: ' + stdout.trim());
|
|
|
|
|
|
- fs.readFile(dstPath, 'utf-8', function(err, tmpJs) {
|
|
|
|
|
|
+ fs.readFile(dstPath, 'utf-8', function(err, bundledJS) {
|
|
if (err) {
|
|
if (err) {
|
|
return callback(err);
|
|
return callback(err);
|
|
}
|
|
}
|
|
hexo.log.i('hexo-renderer-uppyexamples: read: ' + dstPath);
|
|
hexo.log.i('hexo-renderer-uppyexamples: read: ' + dstPath);
|
|
|
|
|
|
- callback(null, tmpJs);
|
|
|
|
|
|
+ callback(null, bundledJS);
|
|
|
|
+
|
|
|
|
+ // @TODO REMOVE THIS MASSIVE HACK!
|
|
|
|
+ // Once this is resolved: https://github.com/hexojs/hexo/issues/1663
|
|
|
|
+ var finalDest = data.path.replace('/src/', '/public/')
|
|
|
|
+ finalDest = finalDest.replace('.es6', '.js');
|
|
|
|
+
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ hexo.log.i('hexo-renderer-uppyexamples: applying hack for: ' + finalDest);
|
|
|
|
+ fs.writeFileSync(finalDest, bundledJS);
|
|
|
|
+ }, 1000)
|
|
|
|
+
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|