diff --git a/index.js b/index.js index e35af68..594ab45 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const debug = require('debug'); const FSTree = require('fs-tree-diff'); const BlankObject = require('blank-object'); const heimdall = require('heimdalljs'); +const fs = require('fs'); function ApplyPatchesSchema() { this.mkdir = 0; @@ -42,6 +43,19 @@ function isNotAPattern(pattern) { return true; } +function existsSync(path) { + let error = {}; + try { + fs.accessSync(path); + fs.statSync(path); + } catch (err) { + error = err; + } + if (error.errno && error.errno !== 0) { + return false; + } + return true; +} class Funnel extends Plugin { constructor(inputNode, options = {}) { @@ -208,6 +222,12 @@ class Funnel extends Plugin { // This is specifically looking for broken symlinks. let outputPathExists = this.output.existsSync('./'); + // We need to keep this till node 10,12 get fix for windows broken symlink issue. + // https://github.com/nodejs/node/issues/30538 + let isWin = process.platform === 'win32'; + if (isWin) { + outputPathExists = existsSync(this.outputPath); + } // Doesn't count as a rebuild if there's not an existing outputPath. this._isRebuild = this._isRebuild && outputPathExists;