From ed267b48a698e3744a5e8bc40ad3c7f7bbb27929 Mon Sep 17 00:00:00 2001 From: Even Stensberg Date: Wed, 28 Dec 2016 08:24:29 +0100 Subject: [PATCH] feat: Introduce reserve and timestamps (#24) --- bin/config-yargs.js | 6 +++++ bin/convert-argv.js | 22 +++++++++---------- bin/process-options.js | 10 +++++---- .../{inquirer-test.js => inquirer.test.js} | 0 4 files changed, 23 insertions(+), 15 deletions(-) rename tests/__tests__/{inquirer-test.js => inquirer.test.js} (100%) diff --git a/bin/config-yargs.js b/bin/config-yargs.js index 4783fd72417..c3291909a80 100644 --- a/bin/config-yargs.js +++ b/bin/config-yargs.js @@ -161,6 +161,12 @@ module.exports = function(yargs) { describe: "Watch the filesystem for changes", group: BASIC_GROUP }, + "save": { + type: "boolean", + alias: "s", + describe: "Rebuilds on save regardless of changes in watch mode", + group: BASIC_GROUP + }, "watch-stdin": { type: "boolean", alias: "stdin", diff --git a/bin/convert-argv.js b/bin/convert-argv.js index 8323d2abf2b..8ea1cc0c9b3 100644 --- a/bin/convert-argv.js +++ b/bin/convert-argv.js @@ -2,7 +2,7 @@ var path = require("path"); var fs = require("fs"); fs.existsSync = fs.existsSync || path.existsSync; var interpret = require("interpret"); -var WebpackOptionsDefaulter = require("../node_modules/webpack/lib/WebpackOptionsDefaulter"); +var WebpackOptionsDefaulter = require("webpack/lib/WebpackOptionsDefaulter"); module.exports = function(yargs, argv, convertOptions) { @@ -317,7 +317,7 @@ module.exports = function(yargs, argv, convertOptions) { defineObject = {}; }, function() { ensureArray(options, "plugins"); - var DefinePlugin = require("../node_modules/webpack/lib/DefinePlugin"); + var DefinePlugin = require("webpack/lib/DefinePlugin"); options.plugins.push(new DefinePlugin(defineObject)); }); @@ -387,13 +387,13 @@ module.exports = function(yargs, argv, convertOptions) { ifBooleanArg("hot", function() { ensureArray(options, "plugins"); - var HotModuleReplacementPlugin = require("../node_modules/webpack/lib/HotModuleReplacementPlugin"); + var HotModuleReplacementPlugin = require("webpack/lib/HotModuleReplacementPlugin"); options.plugins.push(new HotModuleReplacementPlugin()); }); ifBooleanArg("debug", function() { ensureArray(options, "plugins"); - var LoaderOptionsPlugin = require("../node_modules/webpack/lib/LoaderOptionsPlugin"); + var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); options.plugins.push(new LoaderOptionsPlugin({ debug: true })); @@ -427,7 +427,7 @@ module.exports = function(yargs, argv, convertOptions) { ifArg("optimize-max-chunks", function(value) { ensureArray(options, "plugins"); - var LimitChunkCountPlugin = require("../node_modules/webpack/lib/optimize/LimitChunkCountPlugin"); + var LimitChunkCountPlugin = require("webpack/lib/optimize/LimitChunkCountPlugin"); options.plugins.push(new LimitChunkCountPlugin({ maxChunks: parseInt(value, 10) })); @@ -435,7 +435,7 @@ module.exports = function(yargs, argv, convertOptions) { ifArg("optimize-min-chunk-size", function(value) { ensureArray(options, "plugins"); - var MinChunkSizePlugin = require("../node_modules/webpack/lib/optimize/MinChunkSizePlugin"); + var MinChunkSizePlugin = require("webpack/lib/optimize/MinChunkSizePlugin"); options.plugins.push(new MinChunkSizePlugin({ minChunkSize: parseInt(value, 10) })); @@ -443,8 +443,8 @@ module.exports = function(yargs, argv, convertOptions) { ifBooleanArg("optimize-minimize", function() { ensureArray(options, "plugins"); - var UglifyJsPlugin = require("../node_modules/webpack/lib/optimize/UglifyJsPlugin"); - var LoaderOptionsPlugin = require("../node_modules/webpack/lib/LoaderOptionsPlugin"); + var UglifyJsPlugin = require("webpack/lib/optimize/UglifyJsPlugin"); + var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); options.plugins.push(new UglifyJsPlugin({ sourceMap: options.devtool && (options.devtool.indexOf("sourcemap") >= 0 || options.devtool.indexOf("source-map") >= 0) })); @@ -455,7 +455,7 @@ module.exports = function(yargs, argv, convertOptions) { ifArg("prefetch", function(request) { ensureArray(options, "plugins"); - var PrefetchPlugin = require("../node_modules/webpack/PrefetchPlugin"); + var PrefetchPlugin = require("webpack/PrefetchPlugin"); options.plugins.push(new PrefetchPlugin(request)); }); @@ -469,13 +469,13 @@ module.exports = function(yargs, argv, convertOptions) { } else { name = value; } - var ProvidePlugin = require("../node_modules/webpack/ProvidePlugin"); + var ProvidePlugin = require("webpack/ProvidePlugin"); options.plugins.push(new ProvidePlugin(name, value)); }); ifBooleanArg("labeled-modules", function() { ensureArray(options, "plugins"); - var LabeledModulesPlugin = require("../node_modules/webpack/lib/dependencies/LabeledModulesPlugin"); + var LabeledModulesPlugin = require("webpack/lib/dependencies/LabeledModulesPlugin"); options.plugins.push(new LabeledModulesPlugin()); }); diff --git a/bin/process-options.js b/bin/process-options.js index 47f53f3c8a3..f943d4fd38c 100644 --- a/bin/process-options.js +++ b/bin/process-options.js @@ -22,7 +22,7 @@ module.exports = function processOptions(yargs, argv) { var firstOptions = Array.isArray(options) ? (options[0] || {}) : options; if(typeof options.stats === "boolean" || typeof options.stats === "string") { - var statsPresetToOptions = require("../lib/Stats.js").presetToOptions; + var statsPresetToOptions = require("webpack/lib/Stats.js").presetToOptions; options.stats = statsPresetToOptions(options.stats); } @@ -125,7 +125,7 @@ module.exports = function processOptions(yargs, argv) { } }); - var webpack = require("../lib/webpack.js"); + var webpack = require("webpack/lib/webpack.js"); Error.stackTraceLimit = 30; var lastHash = null; @@ -133,7 +133,7 @@ module.exports = function processOptions(yargs, argv) { try { compiler = webpack(options); } catch(e) { - var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError"); + var WebpackOptionsValidationError = require("webpack/lib/WebpackOptionsValidationError"); if(e instanceof WebpackOptionsValidationError) { if(argv.color) console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m"); @@ -145,7 +145,7 @@ module.exports = function processOptions(yargs, argv) { } if(argv.progress) { - var ProgressPlugin = require("../lib/ProgressPlugin"); + var ProgressPlugin = require("webpack/lib/ProgressPlugin"); compiler.apply(new ProgressPlugin({ profile: argv.profile })); @@ -167,7 +167,9 @@ module.exports = function processOptions(yargs, argv) { process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n"); } else if(stats.hash !== lastHash) { lastHash = stats.hash; + process.stdout.write( "\n" + new Date() + "\n" + "\n"); process.stdout.write(stats.toString(outputOptions) + "\n"); + if(argv.s) lastHash = null; } if(!options.watch && stats.hasErrors()) { process.on("exit", function() { diff --git a/tests/__tests__/inquirer-test.js b/tests/__tests__/inquirer.test.js similarity index 100% rename from tests/__tests__/inquirer-test.js rename to tests/__tests__/inquirer.test.js