mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -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.txt'))).to.be('bar\n');
|
||||||
expect(await read(resolve(destination, 'foo_dir/.bar'))).to.be('dotfile\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()', () => {
|
describe('getFileHash()', () => {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { createGunzip } from 'zlib';
|
||||||
import vfs from 'vinyl-fs';
|
import vfs from 'vinyl-fs';
|
||||||
import { promisify } from 'bluebird';
|
import { promisify } from 'bluebird';
|
||||||
import mkdirpCb from 'mkdirp';
|
import mkdirpCb from 'mkdirp';
|
||||||
import { createPromiseFromStreams } from '../../../utils';
|
import { createPromiseFromStreams, createMapStream } from '../../../utils';
|
||||||
|
|
||||||
import { Extract } from 'tar';
|
import { Extract } from 'tar';
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ const chmodAsync = promisify(fs.chmod);
|
||||||
const writeFileAsync = promisify(fs.writeFile);
|
const writeFileAsync = promisify(fs.writeFile);
|
||||||
const readFileAsync = promisify(fs.readFile);
|
const readFileAsync = promisify(fs.readFile);
|
||||||
const readdirAsync = promisify(fs.readdir);
|
const readdirAsync = promisify(fs.readdir);
|
||||||
|
const utimesAsync = promisify(fs.utimes);
|
||||||
|
|
||||||
function assertAbsolute(path) {
|
function assertAbsolute(path) {
|
||||||
if (!isAbsolute(path)) {
|
if (!isAbsolute(path)) {
|
||||||
|
@ -70,6 +71,7 @@ export async function copyAll(sourceDir, destination, options = {}) {
|
||||||
const {
|
const {
|
||||||
select = ['**/*'],
|
select = ['**/*'],
|
||||||
dot = false,
|
dot = false,
|
||||||
|
time,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
assertAbsolute(sourceDir);
|
assertAbsolute(sourceDir);
|
||||||
|
@ -82,8 +84,8 @@ export async function copyAll(sourceDir, destination, options = {}) {
|
||||||
base: sourceDir,
|
base: sourceDir,
|
||||||
dot,
|
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(
|
await copyAll(
|
||||||
build.resolvePath('.'),
|
build.resolvePath('.'),
|
||||||
build.resolvePathForPlatform(platform, '.'),
|
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');
|
log.debug('Generic build source copied into', platform.getName(), 'specific build directory');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue