-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: skip empty files per default on deploy (#56)
- Loading branch information
1 parent
569db4d
commit a2412db
Showing
2 changed files
with
28 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {minimatch} from 'minimatch'; | ||
import {lstatSync, readdirSync} from 'node:fs'; | ||
import {join} from 'node:path'; | ||
import type {SatelliteConfig} from '../types/satellite.config'; | ||
|
||
export const listSourceFiles = ({ | ||
sourceAbsolutePath, | ||
ignore | ||
}: {sourceAbsolutePath: string} & Required<Pick<SatelliteConfig, 'ignore'>>): string[] => { | ||
const sourceFiles = files(sourceAbsolutePath); | ||
|
||
const filteredEmptyFiles = sourceFiles.filter((file) => lstatSync(file).size > 0); | ||
|
||
const filteredSourceFiles = filteredEmptyFiles.filter( | ||
(file) => ignore.find((pattern) => minimatch(file, pattern)) === undefined | ||
); | ||
|
||
return filteredSourceFiles; | ||
}; | ||
|
||
const files = (source: string): string[] => | ||
readdirSync(source).flatMap((file) => { | ||
const path = join(source, file); | ||
return lstatSync(path).isDirectory() ? files(path) : join(path); | ||
}); |