尽管有本地 gulpfile,父目录的 gulpfile 仍强制更改工作目录

Parent directory's gulpfile forces working directory change despite local gulpfile

我正在开发一个使用 gulp 来协助开发的网站。我的结构类似于:

在 Zurb 的 "Foundation for Emails" 目录中时,如果我尝试 运行 以下任何一项:

PowerShell 说:"Changing working directory" 然后 运行 是我主项目文件夹中的默认 gulp 任务。当我从我的 UI 工具包文件夹中 运行 gulp 命令时,不会发生这种情况。

但是,如果我删除主项目文件夹中的 gulpfile.js,所有这三个命令都会按预期工作。发生了什么?我怎样才能让这些命令与父目录中的 gulpfile.js 文件一起工作?

在 Foundaton For Emails 文件夹中打开 package.json,然后将 --gulpfile gulpfile.babel.js 选项添加到所有 npm 脚本:

"scripts": {
  "start": "gulp --gulpfile gulpfile.babel.js",
  "build": "gulp --gulpfile gulpfile.babel.js --production",
  "zip": "gulp --gulpfile gulpfile.babel.js zip --production",
  "litmus": "gulp --gulpfile gulpfile.babel.js litmus --production"
},

这会强制 gulp 使用正确的 gulp 文件,而不是向上遍历目录层次结构。