Skip to content

Commit

Permalink
Remove coffeescript from dependencies.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
STRML committed Apr 24, 2019
1 parent 8fcbed1 commit a859006
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 19 additions & 1 deletion lib/grunt.js
Expand Up @@ -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(filename) {
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 = {};
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -37,7 +37,6 @@
"tool"
],
"dependencies": {
"coffeescript": "~1.10.0",
"dateformat": "~1.0.12",
"eventemitter2": "~0.4.13",
"exit": "~0.1.1",
Expand Down

0 comments on commit a859006

Please sign in to comment.