How to use the config function from grunt

Find comprehensive JavaScript grunt.config code examples handpicked from public code repositorys.

20
21
22
23
24
25
26
27
28
29

function existsFileInOutput(filename) {
  return fs.existsSync(path.join(outputDirectory, filename));
}

grunt.config.init({
  pkg: grunt.file.readJSON(path.join(__dirname, 'fixtures', 'app', 'resources', 'app', 'package.json')),
  'create-windows-installer': {
    config: {
      appDirectory: path.join(__dirname, 'fixtures', 'app'),
fork icon104
star icon392
watch icon21

58
59
60
61
62
63
64
65
66
67
  ('warnings', [])
  ('global-dependencies', helpers.createStore())
  ('.bowerrc', grunt.file.readJSON('.bowerrc'))
  ('bower.json', findBowerJSON(store))
  ('ignore-path', grunt.config.data['bower-install'].ignorePath)
  ('html-file', grunt.config.data['bower-install'].html)
  ('html', grunt.file.read(grunt.config.data['bower-install'].html))
  ('directory', store.get('.bowerrc').directory || 'bower_components')

return store;
fork icon87
star icon0
watch icon1

+ 3 other calls in file

89
90
91
92
93
94
95
96
97
98
for (var name in gruntTasks) {
  if (gruntTasks.hasOwnProperty(name)) {
    // add tasks
    registerGruntTask(name);
    // also add target-specific tasks
    for (var target in grunt.config.get(name)) {
      registerGruntTask(name + ':' + target);
    }
  }
}
fork icon22
star icon167
watch icon4

2
3
4
5
6
7
8
9
10
11
module.exports = {
  options: {
    templateBasePath: /app\//,
    templateFileExtensions: /\.(hbs|hjs|handlebars)/,
    templateRegistration: function(name, template) {
      return grunt.config.process("define('<%= package.namespace %>/") + name + "', [], function(){ return " + template + "; });";
    }
  },
  debug: {
    options: {
fork icon6
star icon18
watch icon4

54
55
56
57
58
59
60
61
62
63
  }
});
// Expose task.requires on `this`.
this.requires = task.requires.bind(task);
// Expose config.requires on `this`.
this.requiresConfig = grunt.config.requires;
// Return an options object with the specified defaults overwritten by task-
// specific overrides, via the "options" property.
this.options = function() {
  var args = [{}].concat(grunt.util.toArray(arguments)).concat([
fork icon3
star icon0
watch icon0

+ 41 other calls in file

12
13
14
15
16
17
18
19
20
21

module.exports = {
        init: {
                src: [
                        './grunt/config.js',
                        './grunt/systems/<%= grunt.config("initSystem") %>.json'
                ],
                overwrite: true,
                replacements: [
                        {
fork icon2
star icon16
watch icon18

+ 9 other calls in file

213
214
215
216
217
218
219
220
221
222
  grunt.log.writeln("Using angular " + grunt.util.pluralize(versions, "version/versions") + ": " + versions.join(', '));
}

versions.forEach(function (version) {
  // .. then create a karma config for it!
  var karmaConfigName = 'angular-' + grunt.config.escape(version);

  if (grunt.option('core') || grunt.option('fast')){
    grunt.config('karma.' + karmaConfigName, {
      options: {
fork icon0
star icon1
watch icon0

+ 21 other calls in file

38
39
40
41
42
43
44
45
46
  // Uncomment these to see the output of the commands.
  // proc.stdout.pipe(process.stdout);
  // proc.stderr.pipe(process.stderr);
}

var pkg = grunt.config.data.pkg;
var tgz = pkg.name + '-' + pkg.version + '.tgz';

grunt.log.writeln('Packing ' + tgz + ' (this could take a while)...');
fork icon0
star icon0
watch icon2

21
22
23
24
25
26
27
28
29
30
  return UglifyJS.minify(src, {fromString: true}).code;
}

// TODO: move this out to another build step maybe.
function bannerify(src) {
  var version = grunt.config.data.pkg.version;
  var packageName = this.data.packageName || this.data.standalone;
  return (
    grunt.template.process(
      LICENSE_TEMPLATE,
fork icon0
star icon0
watch icon2

+ 3 other calls in file

37
38
39
40
41
42
43
44
45
46
    opts: {
      cwd: 'build/',
    },
  };
  grunt.util.spawn(spawnCmd, function() {
    var buildSrc = 'build/react-noop-renderer-' + grunt.config.data.pkg.version + '.tgz';
    var buildDest = 'build/packages/react-noop-renderer.tgz';
    fs.rename(buildSrc, buildDest, done);
  });
}
fork icon0
star icon0
watch icon3

7
8
9
10
11
12
13
14
15
16

// This task is async...
var done = this.async();

// More/better assertions
// grunt.config.requires('outfile');
// grunt.config.requires('entries');
config.transforms = config.transforms || [];
config.after = config.after || [];
if (typeof config.after === 'function') {
fork icon0
star icon0
watch icon2

+ 3 other calls in file

14
15
16
17
18
19
20
21
22
23
console.log("update/tasks/wordpressupdate.js");


grunt.registerTask('pull_site', 'pulls the files and DB from the remote server', function() {
  var target = grunt.option('target') || task_options['target'];
  if ( typeof target === "undefined" || typeof grunt.config.get('wordpressdeploy')[target] === "undefined" || target === "local")  {
    grunt.fail.warn("Invalid target specified. Did you pass the wrong argument? Please check your task configuration.", 6);
  }

  console.log("pulling site from " + target);
fork icon0
star icon0
watch icon1

13
14
15
16
17
18
19
20
21
22
    }));
  process.stdout.write('\n');
};

grunt.task.registerMultiTask('parseApi', 'Api automatic parser', function () {
  var config = grunt.config.get('parseApi'),
    done = this.async(),
    files = grunt.file.expand(config.basePath + '/**/*.mp3'),
    global = [],
    artists = {},
fork icon0
star icon0
watch icon2

74
75
76
77
78
79
80
81
82
83
    grunt.log.error('Make sure you have the react gh-pages branch checked ' +
                    'out at ../react-gh-pages.');
    return false;
  }

  VERSION = grunt.config.data.pkg.version;
  VERSION_STRING = 'v' + VERSION;
}

function bower() {
fork icon0
star icon0
watch icon2

+ 7 other calls in file

10
11
12
13
14
15
16
17
18
19
};

var loadOptions = function(path) {
  glob.sync('*', { cwd: path }).forEach(function(option) {
    var key = option.replace(/\.js$/,'').replace(/^grunt\-/, '');
    grunt.config.set(key, require(path + option));
  });
};

var loadTasks = function(path) {
fork icon0
star icon0
watch icon20

110
111
112
113
114
115
116
117
118
119
//concat
var src = files.map(function(filepath){
  return grunt.file.read(filepath);
}).join(grunt.util.normalizelf('\n'));
//process
var processed = this.process(src, grunt.config('NG_VERSION'), config.strict);
if (styles) processed = this.addStyle(processed, styles.css, styles.minify);
//write
grunt.file.write(config.dest, processed);
grunt.log.ok('File ' + config.dest + ' created.');
fork icon0
star icon0
watch icon5

5
6
7
8
9
10
11
12
13
14
// package. This is not an ideal way to do this, but makes sure that we keep
// them in sync.
var reactVersionExp = /\bReact\.version\s*=\s*['"]([^'"]+)['"];/;

module.exports = function() {
  var pkgVersion = grunt.config.data.pkg.version;

  var versions = {
    'packages/react/package.json':
      grunt.file.readJSON('./packages/react/package.json').version,
fork icon0
star icon0
watch icon2

29
30
31
32
33
34
35
36
37
38
    }
  });

  // modify build/react-core/package.json to set version ##
  var pkg = grunt.file.readJSON(dest + 'package.json');
  pkg.version = grunt.config.data.pkg.version;
  grunt.file.write(dest + 'package.json', JSON.stringify(pkg, null, 2));
}

function buildDev() {
fork icon0
star icon0
watch icon9