I have a number of different JSON files which I use for variables for Grunt to load.
Eg.
Each JSON is for a specific project which I load within a gruntfile.js along with the package.json like so..
pkg: grunt.file.readJSON('package.json'),
template: grunt.file.readJSON('project1.json'),
When changing project I open the gruntfile.js and edit the above code depending which on project I am working on.
My question is, is it possible to define what JSON to load from the Node command line?
Thank you in advance :)
Ciarán
if you run something like node myServer.js project1.json
you can retrieve those arguments in process.argv array
take a look to http://nodejs.org/api/process.html#process_process_argv
Figured this out using grunt.option
pkg: grunt.file.readJSON('package.json'),
project: grunt.option('project'),
template: grunt.file.readJSON(grunt.option('project') + '.json'),
I could then call the json file from the command line using the following..
grunt compress --project=project1
Where project1 is the name of the json file (project1.json) to be loaded.