@@ -23,6 +23,10 @@ import { supported, next, nextNext, deprecated } from '../../lib/enterprise-serv
23
23
import { getLiquidConditionals } from '../../script/helpers/get-liquid-conditionals.js'
24
24
import allowedVersionOperators from '../../lib/liquid-tags/ifversion-supported-operators.js'
25
25
import semver from 'semver'
26
+ import { jest } from '@jest/globals'
27
+ import { getDiffFiles } from '../utils.js'
28
+
29
+ jest . useFakeTimers ( 'legacy' )
26
30
27
31
const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
28
32
const enterpriseServerVersions = Object . keys ( allVersions ) . filter ( ( v ) =>
@@ -357,28 +361,18 @@ function getContent(content) {
357
361
return null
358
362
}
359
363
360
- // Filter out entries from an array like this:
361
- //
362
- // [
363
- // [relativePath, absolutePath],
364
- // ...
365
- // so it's only the files mentioned in the DIFF_FILES environment
366
- // variable, but only if it's set and present.
367
-
368
- // Setting an environment varible called `DIFF_FILES` is optional.
369
- // But if and only if it's set, we will respect it.
370
- // And if it set, turn it into a cleaned up Set so it's made available
371
- // every time we use it.
372
- if ( process . env . DIFF_FILES ) {
373
- // Parse and turn that environment variable string into a set.
364
+ const diffFiles = getDiffFiles ( )
365
+
366
+ // If present, and not empty, leverage it because in most cases it's empty.
367
+ if ( diffFiles . length > 0 ) {
374
368
// It's faster to do this once and then re-use over and over in the
375
369
// .filter() later on.
376
370
const only = new Set (
377
371
// If the environment variable encodes all the names
378
372
// with quotation marks, strip them.
379
373
// E.g. Turn `"foo" "bar"` into ['foo', 'bar']
380
374
// Note, this assumes no possible file contains a space.
381
- process . env . DIFF_FILES . split ( / \s + / g ) . map ( ( name ) => {
375
+ diffFiles . map ( ( name ) => {
382
376
if ( / ^ [ ' " ] / . test ( name ) && / [ ' " ] $ / . test ( name ) ) {
383
377
return name . slice ( 1 , - 1 )
384
378
}
0 commit comments