Skip to content

Commit 6a4a6a0

Browse files
committed
Log that special files were skipped.
This is flushed at the end of the copy command, or on exit if that doesn't happen first.
1 parent b2932cf commit 6a4a6a0

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/common.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@ function log() {
8484
}
8585
exports.log = log;
8686

87+
var _logLater = [];
88+
// facilate logging informational messages at the end of a command
89+
function logLater(message) {
90+
if (!_logLater.length) {
91+
// only logs if outputLaterLog hasn't been called
92+
process.on('exit', outputLaterLog);
93+
}
94+
if (_logLater.indexOf(message) === -1) {
95+
_logLater = _logLater.concat(message);
96+
}
97+
}
98+
exports.logLater = logLater;
99+
100+
function outputLaterLog() {
101+
_logLater.forEach(function (m) {
102+
log(m);
103+
});
104+
_logLater = [];
105+
process.removeListener('exit', outputLaterLog);
106+
}
107+
exports.outputLaterLog = outputLaterLog;
108+
87109
// Converts strings to be equivalent across all platforms. Primarily responsible
88110
// for making sure we use '/' instead of '\' as path separators, but this may be
89111
// expanded in the future if necessary

src/cp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function copyFileSync(srcFile, destFile, options) {
5858
if (srcFileStat.isCharacterDevice()) type = 'block device';
5959
if (srcFileStat.isBlockDevice()) type = 'character device';
6060
common.error('copyFileSync: ' + type + ' is not supported (' + srcFile + ')', { continue: true });
61+
common.logLater('copyFileSync: Special files were encountered during this operation. Please investigate shelljs plugins if you would like to add support for these.');
6162
} else {
6263
var buf = common.buffer();
6364
var bufLength = buf.length;
@@ -308,6 +309,7 @@ function _cp(options, sources, dest) {
308309
}
309310
}); // forEach(src)
310311

312+
common.outputLaterLog();
311313
return new common.ShellString('', common.state.error, common.state.errorCode);
312314
}
313315
module.exports = _cp;

0 commit comments

Comments
 (0)