Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'src' of undefined #2

Closed
davidtheclark opened this issue Apr 23, 2013 · 2 comments
Closed

Cannot read property 'src' of undefined #2

davidtheclark opened this issue Apr 23, 2013 · 2 comments

Comments

@davidtheclark
Copy link

This is my first attempt to use a grunt plugin, so please forgive me if I am missing something obvious -- but I think I'm following the directions from Grunt and from you, and running into an error. My package.json looks like this:

{
  "name": "brink-prototype",
  "version": "0.0.0",
  "dependencies": {
    "bower": "~0.8.6",
    "grunt": "~0.4.1",
    "grunt-regex-replace": "~0.2.2"
  }
}

And my Gruntfile.js looks like this:

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    'regex-replace': {
      src: ['components/bootstrap/less/navbar.less'],
      actions: [
        {
          search: '\.box-shadow(.*);$',
          replace: '',
          flags: ''
        }
      ]
    }
  });
  grunt.loadNpmTasks('grunt-regex-replace');
  grunt.registerTask('default', ['regex-replace']);
};

Now, when I run grunt from the command line I get the following error:

Running "regex-replace:src" (regex-replace) task
Warning: Cannot read property 'src' of undefined Use --force to continue.
Aborted due to warnings.

Do you have any idea what I'm doing wrong? Thanks so much for your help.

@bomsy
Copy link
Owner

bomsy commented Apr 24, 2013

hi,
I think there is a bug in the code. i'm fixing it , will push an update in a few hours.
Cheers

@bomsy
Copy link
Owner

bomsy commented Apr 24, 2013

Fixed! The new version update is 0.2.3. There were some incompatibilities with the changes in grunt 0.4.x.

Update your package.json to

{
  "name": "brink-prototype",
  "version": "0.0.0",
  "dependencies": {
    "bower": "~0.8.6",
    "grunt": "~0.4.1",
    "grunt-regex-replace": "~0.2.3"
  }
}

Update your Gruntfile to look something like this.

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    'regex-replace': {
        foo: {       // a target must be specified with a name
           src: ['components/bootstrap/less/navbar.less'],
           actions: [
                {
                     search: '\.box-shadow(.*);$',
                     replace: '',
                     flags: ''
                }
            ]
         }
    }
  });
  grunt.loadNpmTasks('grunt-regex-replace');
  grunt.registerTask('default', ['regex-replace']);
};

Just specify a target name and your fine.
Let me know.
Cheers

@bomsy bomsy closed this as completed Apr 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants