Assuming the following directory structure:
Project
│ fileA.html
│
└───SubFolderB
│ │ fileB.html
│ │ test.js
If fileA.html references test.js as so:
<script src="js/test.js"></script>
and fileB.html references the same file from its current directory as so:
<script src="test.js"></script>
then using gulp-cache-bust without specifying options.basePath will result in the basePath of the first file in the pipe being used for all files. As such, an error like the following occurs:
Error: ENOENT: no such file or directory, open '\Project\test.js'
at Object.openSync (fs.js:448:3)
at Object.readFileSync (fs.js:348:35)
at Object.self.MD5 (\node_modules\cachebust\lib\cachebust.js:35:23)
at Object.exports.busted (\node_modules\cachebust\lib\cachebust.js:64:40)
at \node_modules\gulp-cache-bust\index.js:47:40
at \node_modules\graceful-fs\graceful-fs.js:90:16
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:54:3)
This will also go wrong if you have a directory structure as such:
Project
└───SubFolderA
│ │ fileA.html
│
└───SubFolderB
│ │ fileB.html
│ │ test.js
and fileA.html as so:
<script src="/js/test.js"></script>
At that point, options.basePath is either set by default to SubFolderA or can be set to Project manually but in either case, an error will occur for fileB.html.
Expected behavior:
Not specifying basePath would result in the basePath of every file being resolved in the pipeline. However to avoid breaking changes, an option.resolveAllBasePath option could be introduced for this behavior.
Alternatively, the documentation could specify to not use paths relative to the current folder as distinct from paths relative to the root or basePath folder.
Assuming the following directory structure:
If
fileA.htmlreferencestest.jsas so:and
fileB.htmlreferences the same file from its current directory as so:then using
gulp-cache-bustwithout specifyingoptions.basePathwill result in thebasePathof the first file in the pipe being used for all files. As such, an error like the following occurs:This will also go wrong if you have a directory structure as such:
and
fileA.htmlas so:At that point,
options.basePathis either set by default toSubFolderAor can be set toProjectmanually but in either case, an error will occur forfileB.html.Expected behavior:
Not specifying
basePathwould result in thebasePathof every file being resolved in the pipeline. However to avoid breaking changes, anoption.resolveAllBasePathoption could be introduced for this behavior.Alternatively, the documentation could specify to not use paths relative to the current folder as distinct from paths relative to the root or
basePathfolder.