diff --git a/lib/extra-files.js b/lib/extra-files.js index 3c8196f46..f992e9dfd 100644 --- a/lib/extra-files.js +++ b/lib/extra-files.js @@ -16,9 +16,11 @@ const OsHelpers = require('./os-helpers'); */ async function collect(requests) { const {globby} = await import('globby'); - const files = await Promise.all( + const files2D = await Promise.all( requests.map((request) => getFiles(globby, request)) - ).then((files) => unique(files.flat())); + ); + const flatFiles = files2D.flat(); + const files = unique(flatFiles); const filesAndContents = await Promise.all( files.map(async (filePath) => { @@ -32,7 +34,7 @@ async function collect(requests) { return filesAndContents.reduce((dict, {path, content}) => { dict[path] = content; return dict; - }, {}); + }, /** @type {NonElmFiles} */ ({})); } /** @@ -44,7 +46,9 @@ function getFiles(globby, request) { return globby( request.files.map( (file) => - (file.included ? '' : '!') + OsHelpers.makePathOsAgnostic(file.pattern) + `${file.included ? '' : '!'}${OsHelpers.makePathOsAgnostic( + file.pattern + )}` ), { ignore: request.excludedDirectories, @@ -58,6 +62,11 @@ function getFiles(globby, request) { ); } +/** + * @template T + * @param {T[]} array + * @returns {T[]} + */ function unique(array) { return [...new Set(array)]; } diff --git a/tsconfig.no-implicit-any.json b/tsconfig.no-implicit-any.json index 620481084..68006159d 100644 --- a/tsconfig.no-implicit-any.json +++ b/tsconfig.no-implicit-any.json @@ -10,6 +10,7 @@ "lib/debug.js", "lib/elm-communication.js", "lib/elm-files.js", + "lib/extra-files.js", "lib/sync-get.js", "lib/sync-get-worker.js", "lib/error-message.js",