diff --git a/.github/scripts/check-tests.mjs b/.github/scripts/check-tests.mjs index fd0cfab2f0..eafe1c3254 100644 --- a/.github/scripts/check-tests.mjs +++ b/.github/scripts/check-tests.mjs @@ -1,13 +1,13 @@ import fs from 'fs'; import path from 'path'; import util from 'util'; -import { exec } from 'child_process'; +import { spawn } from 'child_process'; import { glob } from "glob"; import parser from '@babel/parser'; import traverse from '@babel/traverse'; const readFileAsync = util.promisify(fs.readFile); -const execAsync = util.promisify(exec); +const spawnAsync = util.promisify(spawn); const filterAsync = async (asyncPredicate, arr) => { const filterResults = await Promise.all(arr.map(async item => ({ @@ -44,8 +44,10 @@ const hasFunctionOrClass = async filePath => { const program = async () => { // Run a git command to get a list of all files in the commit - const changedFilesCommand = "git diff --name-only --diff-filter=d origin/master...HEAD"; - const changedFiles = await execAsync(changedFilesCommand).then(stdout => stdout.toString().trim().split('\n').filter(Boolean)); + const changedFiles = await spawnAsync( + 'git', + ['diff', '--name-only', '--diff-filter=d', 'origin/master...HEAD'] + ).then(stdout => stdout.toString().trim().split('\n').filter(Boolean)); // Get all .spec.ts and .test.ts files from the packages const specAndTestTsFiles = await glob('../../packages/*/**/{test,__tests__}/*.{spec,test}.ts');