Skip to content

Commit

Permalink
[build] Update copyAll implementation (elastic#138692)
Browse files Browse the repository at this point in the history
* [build] Update copyAll implementation

* remove unused copy
  • Loading branch information
jbudz authored Aug 12, 2022
1 parent b907080 commit 339f906
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
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) {
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

0 comments on commit 339f906

Please sign in to comment.