Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Update copyAll implementation #138692

Merged
merged 2 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions src/dev/build/lib/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import fs from 'fs';
import Fsp from 'fs/promises';
import { createHash } from 'crypto';
import { Writable } from 'stream';
import { pipeline } from 'stream/promises';
import { resolve, dirname, isAbsolute, sep } from 'path';
import { createGunzip } from 'zlib';
import { inspect } from 'util';

import archiver from 'archiver';
import vfs from 'vinyl-fs';
import File from 'vinyl';
import globby from 'globby';
import cpy from 'cpy';
import del from 'del';
import deleteEmpty from 'delete-empty';
import tar, { ExtractOptions } from 'tar';
Expand Down Expand Up @@ -155,32 +154,24 @@ export async function copyAll(
assertAbsolute(sourceDir);
assertAbsolute(destination);

await pipeline(
vfs.src(select, {
buffer: false,
cwd: sourceDir,
base: sourceDir,
dot,
}),
vfs.dest(destination)
);
const copiedFiles = await cpy(select, destination, {
cwd: sourceDir,
parents: true,
ignoreJunk: false,
dot,
});

// we must update access and modified file times after the file copy
// has completed, otherwise the copy action can effect modify times.
if (time) {
await pipeline(
vfs.src(select, {
buffer: false,
cwd: destination,
base: destination,
dot,
}),
new Writable({
objectMode: true,
write(file: File, _, cb) {
Fsp.utimes(file.path, time, time).then(() => cb(), cb);
},
})
const copiedDirectories = await globby(select, {
cwd: destination,
dot,
onlyDirectories: true,
absolute: true,
});
await Promise.all(
[...copiedFiles, ...copiedDirectories].map((entry) => Fsp.utimes(entry, time, time))
);
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/dev/build/tasks/os_packages/docker_generator/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,6 @@ export async function runDockerGenerator(
dockerBuildDir
);

if (flags.ironbank) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't used, and cpy throws errors if nothing matches. I think that's a reasonable API change, but can catch it if there's any concerns.

await copyAll(
config.resolveFromRepo('src/dev/build/tasks/os_packages/docker_generator/resources/ironbank'),
dockerBuildDir
);
}

// Build docker image into the target folder
// In order to do this we just call the file we
// created from the templates/build_docker_sh.template.js
Expand Down