From 13e46e7603d22bf957e4093b3f28b34096b572b3 Mon Sep 17 00:00:00 2001 From: Lam Wei Li Date: Fri, 8 Apr 2022 23:23:55 +0800 Subject: [PATCH] refactor: replace console.warn with process.emitWarning Signed-off-by: Lam Wei Li --- lib/copy/copy-sync.js | 7 +++++-- lib/copy/copy.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/copy/copy-sync.js b/lib/copy/copy-sync.js index 5e245b91..551abe0c 100644 --- a/lib/copy/copy-sync.js +++ b/lib/copy/copy-sync.js @@ -17,8 +17,11 @@ function copySync (src, dest, opts) { // Warn about using preserveTimestamps on 32-bit node if (opts.preserveTimestamps && process.arch === 'ia32') { - console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n - see https://github.com/jprichardson/node-fs-extra/issues/269`) + process.emitWarning( + 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' + + '\tsee https://github.com/jprichardson/node-fs-extra/issues/269', + 'Warning', 'fs-extra-WARN0002' + ) } const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy', opts) diff --git a/lib/copy/copy.js b/lib/copy/copy.js index 2a2874f3..09d53dfd 100644 --- a/lib/copy/copy.js +++ b/lib/copy/copy.js @@ -23,8 +23,11 @@ function copy (src, dest, opts, cb) { // Warn about using preserveTimestamps on 32-bit node if (opts.preserveTimestamps && process.arch === 'ia32') { - console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n - see https://github.com/jprichardson/node-fs-extra/issues/269`) + process.emitWarning( + 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' + + '\tsee https://github.com/jprichardson/node-fs-extra/issues/269', + 'Warning', 'fs-extra-WARN0001' + ) } stat.checkPaths(src, dest, 'copy', opts, (err, stats) => {