From 69d2e6f41481c09c66361a9938851fc216a6f2de Mon Sep 17 00:00:00 2001 From: Lukas Holzer Date: Mon, 20 Dec 2021 12:42:24 +0100 Subject: [PATCH] chore: fixes an issue on windows (#3865) --- tools/affected-test.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/affected-test.js b/tools/affected-test.js index 463078e8271..2ae6e55add2 100755 --- a/tools/affected-test.js +++ b/tools/affected-test.js @@ -1,6 +1,7 @@ #!/usr/bin/env node // @ts-check const { existsSync, statSync } = require('fs') +const { join } = require('path') const process = require('process') const { grey } = require('chalk') @@ -13,7 +14,9 @@ const { DependencyGraph, fileVisitor, visitorPlugins } = require('./project-grap const getChangedFiles = async (compareTarget = 'origin/main') => { const { stdout } = await execa('git', ['diff', '--name-only', 'HEAD', compareTarget]) - return stdout.split('\n') + // git is using posix paths so adjust them to the operating system by + // using nodes join function + return stdout.split('\n').map((filePath) => join(filePath)) } /** @@ -23,7 +26,9 @@ const getChangedFiles = async (compareTarget = 'origin/main') => { * @returns {string[]} */ const getAffectedFiles = (changedFiles) => { - const testFiles = sync(ava.files) + // glob is using only posix file paths on windows we need the `\` + // by using join the paths are adjusted to the operating system + const testFiles = sync(ava.files).map((filePath) => join(filePath)) // in this case all files are affected if (changedFiles.includes('npm-shrinkwrap.json') || changedFiles.includes('package.json')) {