In Gruntfile.js' initConfig function, I have the following:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;',
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['src/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
I'm creating the pkg variable and then attempting to pull the name from the object under concat.dist, because this is coming from a new grunt-init template. I'm getting Cannot read property 'name' of undefined when running concat:dist. I've verified the existence of the file and the node "name" in the package.json" file.
Given I'm new to node, I'm not sure if these closures persist when calling grunt tasks and if they do, am I using the wrong convention? Is this even possible?
"name"
in yourpackage.json
file? – Trevino