Commit Graph

14 Commits

Author SHA1 Message Date
Dan Poltawski
00cceb7fba MDL-50115 grunt: provide a --root option to set base path
Windows users are not able to run grunt on a subpath due to platform
restrictions. So we provide this option to provide a workaround for that.

Thanks to Ty Delean who proposed this idea.
2016-02-04 12:03:53 +00:00
Dan Poltawski
1aa454eda4 MDL-49817 grunt: handle multiple watched files changed at once
Includes multiple changes to the shifter task to simplify and
support this:
* Use grunt.file for shifter yui 'module' detection rather than our own
  70 line function
* Use grunt.util.spawn rather than our own exec for shifter
* Improve behaviour on various yui subdirectories

We have to add the 'async' depndency to npm because we are running
multiple async operations in the single task. We use async.eachSeries to
run each shifter job sequentally (else the output would be unreadable
when running async).

We also run shifter in non-recursive mode on the module directory so its
not building everything (thanks to Ryan for pointing this out!)
2016-01-28 08:30:04 +00:00
Dan Poltawski
0b777a069b MDL-49817 grunt: make shifter work watch on right place
We mess around with the cwd to find a shifter path, not ideal but avoids
having to refactor the shifter task.

Also fix jshint errors..

1) The gruntfile runs in a nodejs environment and not a browser
environment.

2) There was an uninitialised variable
2016-01-28 08:27:31 +00:00
Dan Poltawski
8efbb7b1a1 MDL-49817 grunt: add watch task
This allows files to be watched and automatically build when changed.

Thanks to David Monllaó for the initial basis for this patch.
2016-01-28 08:27:31 +00:00
Dan Poltawski
5cc5f31101 MDL-49817 grunt: Refactor the uglify task
This is in preperation for the watch task and doing a few things:

1) Switch away from 'grunt.file.expandMapping' to the declarative syntax
   for doing the same thing, as recommended in docs:
   http://gruntjs.com/api/grunt.file#grunt.file.expandmapping

2) Factor the renaming function into shared function so it can be used
   from the watch task too.

3) Shared the file glob'ing pattern for match AMD js files between
   jshint and uglify task (this removes the node_modules exception..
   we should add it to both if we need it).

4) Rename the task configuration - I am just doing this because it looks
   like 'dynamic_mappings' is some how magic config option when you
   look at the manual:
   http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

   But in fact, it's just a task confguration name.
2016-01-28 08:27:30 +00:00
Dan Poltawski
dbf6b40782 MDL-49817 grunt: jslint rename task config and make explict src
Two reasons for this change:
1) The configuration here is confusing, it seems like we are setting the
   'files' option, but in fact we are just generating a task configuration
    called 'files'. Lets try and avoid confusion.

2) It makes it possible for 'watch' to override the src
2016-01-21 15:13:45 +00:00
Andrew Nicols
dc8675fdad Merge branch 'master' of https://github.com/janeklb/moodle 2016-01-12 09:31:09 +00:00
Janek Lasocki-Biczysko
c9b6feea0e MDL-52504 grunt: fixed scope of jshint when in amd directory 2016-01-05 09:59:09 +00:00
Dan Poltawski
a07afffcce MDL-52591 grunt: make shifter task respect --no-color 2015-12-22 18:37:27 +00:00
Dan Poltawski
65d070aec8 MDL-51582 grunt: task improvements
* Introduce the 'css' task - this will give us flexibility to do things
  in future rather than relying on the inbuilt 'less' task (e.g. sourcemap
  generating task which doesn't run by default)

* Introduce 'amd' task which runs only amd tasks

* Introduce 'js' task which runs all JS (amd/shifter) tasks

* Tweak the ordering so that slow shifter always runs last (useful for
  people like me who forget to specif the task)
2015-12-04 10:37:09 +00:00
Dan Poltawski
a4a52e565e MDL-51582 grunt: add less complilation support
Previously we were using recess to build bootstrap base as it was what
was used by the original project. But recess is no longer maintained.

Now we use grunt for building js, it makes sense to use it for less too.

(If you really don't want to use grunt, you almost certainly can just
use lessc -x as it uses the same less.js on backend).
2015-12-04 10:36:45 +00:00
David Monllao
8f76bfb628 MDL-50766 grunt: Check that there are yui modules before running shifter 2015-09-11 15:11:48 +08:00
Damyon Wiese
e67585f8ca MDL-50001 grunt: Make grunt work on windows
Unfortunately, this is not perfect yet. It will build the entire
repository every time - which takes a while because it builds all the
yui modules (On linux it correctly only builds whats in the current dir).
2015-05-05 12:15:59 +08:00
Damyon Wiese
adeb96d28f MDL-49046 javascript: Add support for AMD modules and jquery.
Grunt is the build tool.
2015-02-23 16:23:10 +08:00