Skip to content

Commit d585569

Browse files
committed
Increase support for non-virtual file input
1 parent bb31c9c commit d585569

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

tools/remark/plugins/remark-run-javascript-examples/lib/transformer.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
var exec = require( 'child_process' ).exec;
66
var logger = require( 'debug' );
77
var replace = require( '@stdlib/string/replace' );
8+
var cwd = require( '@stdlib/utils/cwd' );
89

910

1011
// VARIABLES //
@@ -32,7 +33,7 @@ function transformer( tree, file, clbk ) {
3233
var FLG;
3334
var idx;
3435

35-
debug( 'Processing file: %s', file.path );
36+
debug( 'Processing file: %s', file.path || '' );
3637

3738
idx = -1;
3839
total = tree.children.length;
@@ -83,7 +84,7 @@ function transformer( tree, file, clbk ) {
8384

8485
// Set the working directory of the script to the file directory:
8586
opts = {
86-
'cwd': file.dirname
87+
'cwd': file.dirname || cwd()
8788
};
8889

8990
debug( 'Executing code block...' );
@@ -107,7 +108,7 @@ function transformer( tree, file, clbk ) {
107108
debug( 'Encountered an error when executing code block: %s', error.message );
108109

109110
// TODO: the generated error is a bit messy. Cleaning-up may require manual modification of the stacktrace(s), etc.
110-
error = new Error( 'unexpected error. Encountered an error when executing code block. File: ' + file.path + '. Message: ' + error.message );
111+
error = new Error( 'unexpected error. Encountered an error when executing code block. File: ' + (file.path || '') + '. Message: ' + error.message );
111112
return done( error );
112113
}
113114
stdout = stdout.toString();

0 commit comments

Comments
 (0)