From 2a84fa3ae350e098a53d9bf7d578bc474e989a57 Mon Sep 17 00:00:00 2001 From: Karol Gorski Date: Fri, 25 Jan 2019 20:42:53 +0100 Subject: [PATCH] Add watcher on Linux: change fs to node-watch (#13448) * Add watcher on Linux: change fs to node-watch * Add watcher on Linux: Change fs to node-watch (pt.2.) * Add watcher on Linux: Change fs to node-watch (pt.3.) * Framework: Regenerate package-lock.json --- bin/packages/watch.js | 5 +++-- package-lock.json | 6 ++++++ package.json | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/packages/watch.js b/bin/packages/watch.js index d12d5410f2b7f..fce8a6beedb97 100644 --- a/bin/packages/watch.js +++ b/bin/packages/watch.js @@ -2,6 +2,7 @@ * External dependencies */ const fs = require( 'fs' ); +const watch = require( 'node-watch' ); const { execSync } = require( 'child_process' ); const path = require( 'path' ); const chalk = require( 'chalk' ); @@ -33,13 +34,13 @@ getPackages().forEach( ( p ) => { const srcDir = path.resolve( p, 'src' ); try { fs.accessSync( srcDir, fs.F_OK ); - fs.watch( path.resolve( p, 'src' ), { recursive: true }, ( event, filename ) => { + watch( path.resolve( p, 'src' ), { recursive: true }, ( event, filename ) => { if ( ! isSourceFile( filename ) ) { return; } const filePath = path.resolve( srcDir, filename ); - if ( ( event === 'change' || event === 'rename' ) && exists( filePath ) ) { + if ( ( event === 'update' ) && exists( filePath ) ) { // eslint-disable-next-line no-console console.log( chalk.green( '->' ), `${ event }: ${ filename }` ); rebuild( filePath ); diff --git a/package-lock.json b/package-lock.json index ca8a4feba01f5..30246ca516f38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13819,6 +13819,12 @@ } } }, + "node-watch": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.6.0.tgz", + "integrity": "sha512-XAgTL05z75ptd7JSVejH1a2Dm1zmXYhuDr9l230Qk6Z7/7GPcnAs/UyJJ4ggsXSvWil8iOzwQLW0zuGUvHpG8g==", + "dev": true + }, "nomnom": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.6.2.tgz", diff --git a/package.json b/package.json index ca66510ec46b6..c59a6c200a189 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "lodash": "4.17.10", "mkdirp": "0.5.1", "node-sass": "4.11.0", + "node-watch": "0.6.0", "pegjs": "0.10.0", "phpegjs": "1.0.0-beta7", "react-dom": "16.6.3",