mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
parent
dda84d7570
commit
283dca9348
3 changed files with 38 additions and 4 deletions
|
@ -250,6 +250,22 @@ describe('dev/build/lib/fs', () => {
|
|||
expect(await read(resolve(destination, 'foo_dir/bar.txt'))).to.be('bar\n');
|
||||
expect(await read(resolve(destination, 'foo_dir/.bar'))).to.be('dotfile\n');
|
||||
});
|
||||
|
||||
it('supports atime and mtime', async () => {
|
||||
const destination = resolve(TMP, 'a/b/c/d/e');
|
||||
const time = new Date(1425298511000);
|
||||
await copyAll(FIXTURES, destination, {
|
||||
time
|
||||
});
|
||||
const barTxt = statSync(resolve(destination, 'foo_dir/bar.txt'));
|
||||
const fooDir = statSync(resolve(destination, 'foo_dir'));
|
||||
|
||||
// precision is platform specific
|
||||
const oneDay = 86400000;
|
||||
expect(Math.abs(barTxt.atimeMs - time.getTime())).to.be.below(oneDay);
|
||||
expect(Math.abs(fooDir.atimeMs - time.getTime())).to.be.below(oneDay);
|
||||
expect(Math.abs(barTxt.mtimeMs - time.getTime())).to.be.below(oneDay);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFileHash()', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@ import { createGunzip } from 'zlib';
|
|||
import vfs from 'vinyl-fs';
|
||||
import { promisify } from 'bluebird';
|
||||
import mkdirpCb from 'mkdirp';
|
||||
import { createPromiseFromStreams } from '../../../utils';
|
||||
import { createPromiseFromStreams, createMapStream } from '../../../utils';
|
||||
|
||||
import { Extract } from 'tar';
|
||||
|
||||
|
@ -16,6 +16,7 @@ const chmodAsync = promisify(fs.chmod);
|
|||
const writeFileAsync = promisify(fs.writeFile);
|
||||
const readFileAsync = promisify(fs.readFile);
|
||||
const readdirAsync = promisify(fs.readdir);
|
||||
const utimesAsync = promisify(fs.utimes);
|
||||
|
||||
function assertAbsolute(path) {
|
||||
if (!isAbsolute(path)) {
|
||||
|
@ -70,6 +71,7 @@ export async function copyAll(sourceDir, destination, options = {}) {
|
|||
const {
|
||||
select = ['**/*'],
|
||||
dot = false,
|
||||
time,
|
||||
} = options;
|
||||
|
||||
assertAbsolute(sourceDir);
|
||||
|
@ -82,8 +84,8 @@ export async function copyAll(sourceDir, destination, options = {}) {
|
|||
base: sourceDir,
|
||||
dot,
|
||||
}),
|
||||
|
||||
vfs.dest(destination)
|
||||
vfs.dest(destination),
|
||||
...(Boolean(time) ? [createMapStream(file => utimesAsync(file.path, time, time))] : []),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,23 @@ export const CreateArchivesSourcesTask = {
|
|||
await copyAll(
|
||||
build.resolvePath('.'),
|
||||
build.resolvePathForPlatform(platform, '.'),
|
||||
{ dot: true },
|
||||
{
|
||||
select: [
|
||||
'**/*',
|
||||
'!node_modules/**',
|
||||
],
|
||||
dot: true,
|
||||
},
|
||||
);
|
||||
|
||||
const currentTime = new Date();
|
||||
await copyAll(
|
||||
build.resolvePath('node_modules'),
|
||||
build.resolvePathForPlatform(platform, 'node_modules'),
|
||||
{
|
||||
dot: true,
|
||||
time: currentTime
|
||||
},
|
||||
);
|
||||
log.debug('Generic build source copied into', platform.getName(), 'specific build directory');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue