@@ -9,29 +9,29 @@ import { getDuration } from './utils/get-duration'
99import { getFileHashes } from './utils/get-file-hashes'
1010import { getFilePaths } from './utils/get-file-paths'
1111
12- interface DebounceCommandProps {
12+ interface RunCommandProps {
1313 relativeCacheDirectory : string | undefined
1414 command : string
15- debounceByTime : string | undefined
16- debounceByFiles : string [ ]
15+ cacheByTime : string | undefined
16+ cacheByFiles : string [ ]
1717 shouldCacheOnError : boolean | undefined
1818}
1919
20- export async function debounceCommand ( {
20+ export async function runCommand ( {
2121 relativeCacheDirectory,
2222 command,
23- debounceByTime ,
24- debounceByFiles ,
23+ cacheByTime : cacheByTime ,
24+ cacheByFiles : cacheByFiles ,
2525 shouldCacheOnError,
26- } : DebounceCommandProps ) {
27- if ( ! debounceByTime && debounceByFiles . length === 0 ) {
26+ } : RunCommandProps ) {
27+ if ( ! cacheByTime && cacheByFiles . length === 0 ) {
2828 await execSh . promise ( command )
2929 return
3030 }
3131
3232 const cache = flatCache . load ( 'commands-cache.json' , createCache ( relativeCacheDirectory ) )
33- const filePaths = getFilePaths ( debounceByFiles )
34- const duration = debounceByTime ? getDuration ( debounceByTime ) : undefined
33+ const filePaths = getFilePaths ( cacheByFiles )
34+ const duration = cacheByTime ? getDuration ( cacheByTime ) : undefined
3535
3636 const cacheKey = getCacheKey ( { duration, filePaths, command } )
3737
@@ -41,7 +41,7 @@ export async function debounceCommand({
4141 const currentDate = new Date ( )
4242
4343 const areFileHashesEqual = isEqual ( ( cacheData as any ) ?. fileHashes , fileHashes )
44- const isCurrentTimeInDebounce = ( ( ) => {
44+ const isWithinCacheTime = ( ( ) => {
4545 if ( ! duration ) {
4646 return true
4747 }
@@ -55,7 +55,7 @@ export async function debounceCommand({
5555 return isAfter ( add ( new Date ( lastRun ) , duration ) , currentDate )
5656 } ) ( )
5757
58- if ( areFileHashesEqual && isCurrentTimeInDebounce ) {
58+ if ( areFileHashesEqual && isWithinCacheTime ) {
5959 return
6060 }
6161
0 commit comments