From cde7498c8e3373e2d4b8295f6c7b52826bbce119 Mon Sep 17 00:00:00 2001 From: Trevor Burnham Date: Thu, 28 Apr 2011 18:27:40 -0400 Subject: [PATCH 1/2] Setting process.argv[0] to 'coffee' in 'coffee foo.coffee' See #1301 et al. --- lib/coffee-script.js | 1 + src/coffee-script.coffee | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/coffee-script.js b/lib/coffee-script.js index 7b3347145e..ff233ace5a 100755 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -49,6 +49,7 @@ while (root.parent) { root = root.parent; } + process.argv[0] = 'coffee'; root.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.'; if (root.moduleCache) { root.moduleCache = {}; diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index b3cc9563cb..8a28e78761 100755 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -57,6 +57,10 @@ exports.run = (code, options) -> root = module while root.parent root = root.parent + + # Set the process command to `coffee` + process.argv[0] = 'coffee' + # Set the filename. root.filename = process.argv[1] = if options.filename then fs.realpathSync(options.filename) else '.' From fe889b8428597ce2be5b13d75aac265de77b5c33 Mon Sep 17 00:00:00 2001 From: Trevor Burnham Date: Thu, 28 Apr 2011 18:35:42 -0400 Subject: [PATCH 2/2] Setting process.argv[0] to 'coffee' in the REPL (aesthetic) --- lib/coffee-script.js | 1 + src/coffee-script.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/coffee-script.js b/lib/coffee-script.js index ff233ace5a..a3dd292937 100755 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -66,6 +66,7 @@ }; exports.eval = function(code, options) { var __dirname, __filename; + process.argv[0] = 'coffee'; __filename = module.filename = process.argv[1] = options.filename; __dirname = path.dirname(__filename); return eval(compile(code, options)); diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 8a28e78761..a10b57d7fd 100755 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -82,6 +82,7 @@ exports.run = (code, options) -> # Compile and evaluate a string of CoffeeScript (in a Node.js-like environment). # The CoffeeScript REPL uses this to run the input. exports.eval = (code, options) -> + process.argv[0] = 'coffee' __filename = module.filename = process.argv[1] = options.filename __dirname = path.dirname __filename eval compile code, options