-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker-build): Add "--copy" option
- Loading branch information
Showing
4 changed files
with
60 additions
and
1 deletion.
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
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,35 @@ | ||
import { PortablePath, xfs, ppath, toFilename } from '@yarnpkg/fslib'; | ||
import { Report } from '@yarnpkg/core'; | ||
|
||
function resolvePath(baseDir: PortablePath, inputPath: string): PortablePath { | ||
const path = toFilename(inputPath); | ||
|
||
if (ppath.isAbsolute(path)) { | ||
return ppath.relative(baseDir, path); | ||
} | ||
|
||
return path; | ||
} | ||
|
||
export default async function copyAdditional({ | ||
destination, | ||
files, | ||
dockerFilePath, | ||
report, | ||
}: { | ||
destination: PortablePath; | ||
files: string[]; | ||
dockerFilePath: PortablePath; | ||
report: Report; | ||
}): Promise<void> { | ||
const baseDir = ppath.dirname(dockerFilePath); | ||
|
||
for (const file of files) { | ||
const path = resolvePath(baseDir, file); | ||
const src = ppath.join(baseDir, path); | ||
const dest = ppath.join(destination, path); | ||
|
||
report.reportInfo(null, path); | ||
await xfs.copyPromise(dest, src); | ||
} | ||
} |
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