From dd9385e7e6982c04e097994b496d005faa73b199 Mon Sep 17 00:00:00 2001 From: Geoff Kimball Date: Tue, 17 Nov 2015 22:59:13 -0800 Subject: [PATCH] Change "foundation build" command to run "npm run build" --- lib/commands/build.js | 18 ++++++++++++++++-- lib/commands/watch.js | 12 +++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/commands/build.js b/lib/commands/build.js index fa509b4..da996c1 100644 --- a/lib/commands/build.js +++ b/lib/commands/build.js @@ -1,3 +1,17 @@ +var fs = require('fs'); +var npm = require('npm'); +var path = require('path'); + module.exports = function(args, options) { - this.watch(args, options, true) -} \ No newline at end of file + // Check if the user is inside a project folder, by looking for a package.json + if (!fs.existsSync(path.join(process.cwd(), 'package.json'))) { + console.log("\nYou don't appear to be in a Foundation project folder.\n\nUse " + "pwd".cyan + " (or " + "chdir".cyan + " on Windows) to see what folder you're in.\n"); + process.exit(0); + } + + var args = ['build']; + + npm.load({ prefix: process.cwd(), loaded: false }, function(err) { + npm.commands['run-script'].apply(this, [args]); + }); +} diff --git a/lib/commands/watch.js b/lib/commands/watch.js index 928c21f..9905c0e 100644 --- a/lib/commands/watch.js +++ b/lib/commands/watch.js @@ -2,20 +2,14 @@ var fs = require('fs'); var npm = require('npm'); var path = require('path'); -module.exports = function(args, options, justBuild) { - var cmd = []; - +module.exports = function(args, options) { // Check if the user is inside a project folder, by looking for a package.json if (!fs.existsSync(path.join(process.cwd(), 'package.json'))) { console.log("\nYou don't appear to be in a Foundation project folder.\n\nUse " + "pwd".cyan + " (or " + "chdir".cyan + " on Windows) to see what folder you're in.\n"); process.exit(0); } - if (justBuild) { - cmd.push('build'); - } - npm.load({ prefix: process.cwd(), loaded: false }, function(err) { - npm.commands.start.apply(this, cmd); + npm.commands.start.apply(this, []); }); -} \ No newline at end of file +}