Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Gulp watch does not trigger for new files #11

Closed
montalvomiguelo opened this issue Nov 25, 2018 · 0 comments
Closed

Gulp watch does not trigger for new files #11

montalvomiguelo opened this issue Nov 25, 2018 · 0 comments

Comments

@montalvomiguelo
Copy link
Contributor

Problem

Currently gulp is not triggering the tasks copy & contact when new files are added to the source directory. They are only being triggered when the files have been changed.

fail-new-files

How to fix (lib/gulp.js)

If the glob string provided to the watch task is an absolute path starting with a / then gulp will not trigger for new files.

We can pass an options argument to the watch tasks and set the cwd property with the directory that will be used to build absolute paths.

watch () {
  gulp.watch(
+   'src/**/*.*',
+   {cwd: config.get('cwd')},
    e => {
      try {
        this.copy(e, true)
      } catch (e) {
        new Err(e)
      }
    }
  )
  gulp.watch(
+   'src/config/**',
+   {cwd: config.get('cwd')},
    e => {
      try {
        this.concat(true)
      } catch (e) {
        new Err(e)
      }
    }
  )
}

Also update the copy method and check if the type of the event was added.

+  if (type === 'changed' || type === 'added') {
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant