Browse Source

Skip copySync preserveTimestamp tests on older node versions

ci/travis-osximage
Mani Maghsoudlou 7 years ago
parent
commit
5bdbdc4fc8
  1. 7
      lib/copy-sync/__tests__/copy-sync-preserve-time.test.js
  2. 8
      lib/copy-sync/copy-sync.js

7
lib/copy-sync/__tests__/copy-sync-preserve-time.test.js

@ -5,14 +5,17 @@ const os = require('os')
const path = require('path')
const utimes = require('../../util/utimes')
const assert = require('assert')
const nodeVersion = process.versions.node
const nodeVersionMajor = parseInt(nodeVersion.split('.')[0], 10)
/* global beforeEach, afterEach, describe, it */
if (process.arch === 'ia32') console.warn('32 bit arch; skipping copySync timestamp tests')
if (nodeVersionMajor < 8) console.warn(`old node version (v${nodeVersion}); skipping copySync timestamp tests`)
const describeIf64 = process.arch === 'ia32' ? describe.skip : describe
const describeIfPractical = (process.arch === 'ia32' || nodeVersionMajor < 8) ? describe.skip : describe
describeIf64('copySync() - preserveTimestamps option', () => {
describeIfPractical('copySync() - preserveTimestamps option', () => {
let TEST_DIR, src, dest
beforeEach(done => {

8
lib/copy-sync/copy-sync.js

@ -74,7 +74,7 @@ function mayCopyFile (srcStat, src, dest, opts) {
}
function copyFile (srcStat, src, dest, opts) {
if (typeof fs.copyFile === 'function') {
if (typeof fs.copyFileSync === 'function') {
fs.copyFileSync(src, dest)
fs.chmodSync(dest, srcStat.mode)
if (opts.preserveTimestamps) {
@ -100,12 +100,10 @@ function copyFileFallback (srcStat, src, dest, opts) {
pos += bytesRead
}
if (opts.preserveTimestamps) fs.futimesSync(fdw, srcStat.atime, srcStat.mtime)
fs.closeSync(fdr)
fs.closeSync(fdw)
fs.chmodSync(dest, srcStat.mode)
if (opts.preserveTimestamps) {
return utimesSync(dest, srcStat.atime, srcStat.mtime)
}
}
function onDir (srcStat, src, dest, opts) {

Loading…
Cancel
Save