From 28c402ff36eb295ea3c67b1e79983c4e56c30539 Mon Sep 17 00:00:00 2001 From: Garren Smith Date: Wed, 25 Jan 2017 10:42:29 +0200 Subject: [PATCH] Convert copy dependencies to use fs-extra --- package.json | 1 + tasks/fauxton.js | 44 ++++++++++++++------------------------------ 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 9557031e7..59c152b7e 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "express": "^4.13.4", "file-loader": "^0.8.5", "flux": "^3.1.0", + "fs-extra": "^2.0.0", "grunt": "~0.4.1", "grunt-chmod": "^1.0.3", "grunt-cli": "~0.1.6", diff --git a/tasks/fauxton.js b/tasks/fauxton.js index d929e8959..5b03b03b1 100644 --- a/tasks/fauxton.js +++ b/tasks/fauxton.js @@ -26,44 +26,28 @@ module.exports = function (grunt) { grunt.registerMultiTask('get_deps', 'Fetch external dependencies', function () { grunt.log.writeln('Fetching external dependencies'); - var done = this.async(), - data = this.data, + const data = this.data, target = data.target || 'app/addons/', settingsFile = fs.existsSync(data.src) ? data.src : 'settings.json.default.json', - settings = grunt.file.readJSON(settingsFile), - _ = grunt.util._; - - // This should probably be a helper, though they seem to have been removed - var fetch = function (deps, command) { - var child_process = require('child_process'); - var async = require('async'); - async.forEach(deps, function (dep, cb) { - var path = target + dep.name; - var location = dep.url || dep.path; - grunt.log.writeln('Fetching: ' + dep.name + ' (' + location + ')'); + settings = grunt.file.readJSON(settingsFile); - child_process.exec(command(dep, path), function (error, stdout, stderr) { - grunt.log.writeln(stderr); - grunt.log.writeln(stdout); - cb(error); - }); - }, function (error) { - if (error) { - grunt.log.writeln('ERROR: ' + error.message); + const fetch = deps => { + var fs = require('fs-extra'); + deps.forEach(dep => { + const path = target + dep.name; + const location = dep.url || dep.path; + grunt.log.writeln('Fetching: ' + dep.name + ' (' + location + ')'); + try { + fs.copySync(dep.path, path); + } catch (e) { + grunt.log.writeln('ERROR: ' + e.message); } - - done(); }); }; - var localDeps = _.filter(settings.deps, function (dep) { return !! dep.path; }); + const localDeps = settings.deps.filter(dep => !!dep.path); grunt.log.writeln(localDeps.length + ' local dependencies'); - fetch(localDeps, function (dep, destination) { - // TODO: Windows - var command = 'cp -r ' + dep.path + '/ ' + destination + '/'; - grunt.log.writeln(command); - return command; - }); + fetch(localDeps); }); grunt.registerMultiTask('gen_load_addons', 'Generate the load_addons.js file', function () {