From ba492b6c6304596461b7fcfe6db6869640ed2fa1 Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Wed, 24 Apr 2019 16:39:18 -0500 Subject: [PATCH] Remove coffeescript from dependencies. To ease transition, if the coffeescript package is still around, Grunt will attempt to load it. If it is not, and the user loads a CoffeeScript file, Grunt will print a useful error indicating that the coffeescript package should be installed as a dev dependency. --- lib/grunt.js | 20 +++++++++++++++++++- package.json | 1 - 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/grunt.js b/lib/grunt.js index 4540d7ca2..025333307 100644 --- a/lib/grunt.js +++ b/lib/grunt.js @@ -4,7 +4,25 @@ var path = require('path'); // This allows grunt to require() .coffee files. -require('coffeescript/register'); +try { + // Note: grunt no longer depends on CoffeeScript, it will only use it if it is intentionally + // installed in the project. + require('coffeescript/register'); +} catch (e) { + // This is fine, and will cause no problems so long as the user doesn't load .coffee files. + // Print a useful error if we attempt to load a .coffee file. + if (require.extensions) { + var FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md']; + for (var i = 0; i < FILE_EXTENSIONS.length; i++) { + require.extensions[FILE_EXTENSIONS[i]] = function() { + throw new Error( + 'Grunt attempted to load a .coffee file but CoffeeScript was not installed.\n' + + 'Please run `npm install --dev coffeescript` to enable loading CoffeeScript.' + ); + }; + } + } +} // The module to be exported. var grunt = module.exports = {}; diff --git a/package.json b/package.json index 9726e8f0d..1c358bdb0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "tool" ], "dependencies": { - "coffeescript": "~1.10.0", "dateformat": "~1.0.12", "eventemitter2": "~0.4.13", "exit": "~0.1.1",