Running grunt.file.copy returns an error code: ENOENT

I want to copy the directory to another location using the Grunt task. I don’t want this to be done in my default task where copying is done, so I am registering a new task for it called "myTask" using the following code:

  grunt.registerTask('myTask', 'Make new dir and copy "src" there', function() {
    grunt.file.copy('src/*','../dest/');
  });

Whenever I run myTask, it tells me:

Warning: it is not possible to read the file "src / *" (error code: ENOENT). Use -force to continue.

Is there any syntax for the source directory I'm copying from?

+4
source share
1 answer

, copy, default... , default:

grunt.initConfig({
  copy: {
    js: {
      files: [{
        expand: true,
        src: ['path/to/js/*.js'],
        dest: 'dest/js'
      }]
    },
    otherstuff: {
      files: [{
        expand: true,
        src: ['src/**'],
        dest: 'dest/'
      }]
    }
  },
  // ...
});

// notice that in our default task we specify "copy:js"
grunt.registerTask('default', ['jshint', 'concat', /* etc, */ 'copy:js']);

~$ grunt copy:otherstuff ~$ grunt copy:js, ~$ grunt, , copy:js.

+1

Source: https://habr.com/ru/post/1570033/


All Articles