How to use the gaze function in gaze

To help you get started, we’ve selected a few gaze examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FWeinb / metalsmith-watch / src / index.es View on Github external
// metalsmith-collections fix: keep filename as metadata
    saveFilenameInFilesData(files)

    const patterns = {}
    Object.keys(options.paths).map(pattern => {
      let watchPattern = pattern.replace("${source}", metalsmith.source())
      if (!isAbsolutePath(watchPattern)){
        watchPattern = resolvePath(metalsmith.directory(), pattern);
      }
      const watchPatternRelative = relativePath(metalsmith.directory(), watchPattern)

      patterns[watchPatternRelative] = options.paths[pattern]
    })

    gaze(
      Object.keys(patterns),
      {
        ...options.gaze,
        cwd: metalsmith._directory,
      },
      function watcherReady(err, watcher) {
        if (err) {throw err}

        Object.keys(patterns).forEach(pattern => {
          options.log(`${ok} Watching ${color.cyan(pattern)}`)
        })

        const previousFilesMap = {...files}

        // Delay watch update to be able to bundle multiples update in the same build
        // Saving multiples files at the same time create multiples build otherwise
github skovhus / css-modules-flow-types / packages / css-modules-flow-types-cli / src / cli.js View on Github external
if (!watch) {
    const cssFiles = filesList ? filesList : globby.sync(filesPattern);
    cssFiles.forEach(handleFile);

    if (!filesList) {
      detectDanlingFlowFiles(filesPattern, cssFiles);
    }
  } else {
    if (!filePath) {
      console.error(
        chalk.red(`Watch mode requires a single path... Not ${filesList}`)
      );
      return;
    }
    gaze(filesPattern, function(err, files) {
      this.on('changed', handleFile);
      this.on('added', handleFile);
    });
  }
};
github start-react / sb-admin-seed-react / tools / copy.js View on Github external
const watcher = await new Promise((resolve, reject) => {
      gaze('src/content/**/*.*', (err, val) => err ? reject(err) : resolve(val));
    });
github phoomparin / FlipED / tools / copy.js View on Github external
const watcher = await new Promise((resolve, reject) => {
      gaze("src/public/*", (err, val) => (err ? reject(err) : resolve(val)))
    })
github Jacky-fe / react-isomorphic-skeleton / tools / copy.js View on Github external
const configWatcher = await new Promise((resolve, reject) => {
      gaze('config.js', (err, val) => err ? reject(err) : resolve(val));
    });
    configWatcher.on('changed', () => {
github chrisdothtml / hyper-stylesheet / lib / stylesheet / _watcher.js View on Github external
start (watchPath, updatePath) {
    gaze(watchPath, (err, watcher) => {
      if (err) {
        error('file watcher error', err.message)
      } else {
        Object.assign(this.state, { isWatching: true })

        watcher.on('changed', () => {
          updateHash({ updatePath, watchPath })
            .catch(err => error('error updating .hyper.js', err.message))
        })

        watcher.on('deleted', () => {
          warn('`.hyper.css` was deleted; autoReload disabled')
          this.stop()
        })

        this.instance = watcher
github insoftpub / storefront / tools / copy.js View on Github external
const watcher = await new Promise((resolve, reject) => {
            gaze('src/content/**/*.*', (err, val) => err ? reject(err) : resolve(val));
        });
github chrisdothtml / hyper-stylesheet / lib / watch.js View on Github external
export default function watch () {
  gaze(STYLESHEET_PATH, (error, watch) => {
    if (error) throw error

    watch.on('deleted', () => {
      watch.close()
      store.fileExists = false
      store.isWatching = false
    })

    watch.on('changed', () => {
      if (store.options['auto-reload']) {
        updateHash()
      }
    })

    store.isWatching = true
  })

gaze

A globbing fs.watch wrapper built from the best parts of other fine watch libs.

MIT
Latest version published 6 years ago

Package Health Score

68 / 100
Full package analysis

Popular gaze functions