Skip to content

Commit

Permalink
feat(layer): add option to overwrite install command
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Apr 25, 2024
1 parent f8d2412 commit b480b67
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/packLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const packLayer = async ({
dependencies,
baseDir,
distDir,
installCommand,
}: {
id: string
dependencies: string[]
Expand All @@ -25,6 +26,13 @@ export const packLayer = async ({
* @default ${baseDir}/dist/layers
*/
distDir?: string
/**
* Returns the command to run, the first element is the command (e.g. `npm`) and the rest are its arguments.
*/
installCommand?: (args: {
packageFile: string
packageLockFile: string
}) => [string, ...Array<string>]
}): Promise<PackedLayer> => {
const base = baseDir ?? process.cwd()
const dist = distDir ?? path.join(base, 'dist', 'layers')
Expand Down Expand Up @@ -88,7 +96,10 @@ export const packLayer = async ({
}

await new Promise<void>((resolve, reject) => {
const [cmd, ...args] = [
const [cmd, ...args] = installCommand?.({
packageFile: packageJSON,
packageLockFile: packageLockJsonFile,
}) ?? [
'npm',
hasLockFile ? 'ci' : 'i',
'--ignore-scripts',
Expand Down

0 comments on commit b480b67

Please sign in to comment.