Frage

My Gruntfile.js:

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        copy: {
            iisDeploy: {
                options: {
                    process: function (content, srcpath) {
                    return content.replace("pre-release", "v" + pkg.version);
                }
            },
            files: [
                { expand: true, cwd: 'build/pre-release/', src: '**', dest: '/location/v<%= pkg.version %>/' }
            ]
        }
    })
}

The task is failing on the pkg.version bit. I've tried a number of things and none of them seem to work. I'm sure it's a scope thing, but I can't for the life of me figure out what it might be. Would love any assistance!

War es hilfreich?

Lösung

Just store the pkg in a variable:

module.exports = function(grunt) {
    var pkg = grunt.file.readJSON('package.json');
    grunt.initConfig({
        pkg: pkg,
        copy: {
            iisDeploy: {
                options: {
                    process: function (content, srcpath) {
                    return content.replace("pre-release", "v" + pkg.version);
                }
            },
            files: [
                { expand: true, cwd: 'build/pre-release/', src: '**', dest: '/location/v<%= pkg.version %>/' }
            ]
        }
    })
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top