From 2ae3cd89b2221c884cbc4648142603edacc88f7d Mon Sep 17 00:00:00 2001 From: Christian Dittrich Date: Thu, 9 Apr 2015 14:20:45 +0200 Subject: [PATCH] Fixed complied files not being renamed on Windows (see https://github.com/jenius/roots/issues/588) --- lib/config.coffee | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/config.coffee b/lib/config.coffee index afcec5ad..fc331326 100644 --- a/lib/config.coffee +++ b/lib/config.coffee @@ -11,6 +11,13 @@ os = require('os') ### class Config + ###* + * This is an escaped version of the platform specific path seperator to be + * used in regular expressions. It is defined as a (derived) constant, + * because the path seperator does not change over the course of a run. + ### + + PATH_SEPERATOR_REGEXP_STRING = path.sep.replace '\\', '\\\\' ###* * Creates a new instance of the roots config. This happens once, as soon as @@ -141,10 +148,7 @@ class Config res.unshift(@output_path()) res = res.join(path.sep) if ext - if (os.platform() is 'win32') - res = res.replace(///\.[^\#{path.sep}]*$///, ".#{ext}") - else - res = res.replace(///\.[^#{path.sep}]*$///, ".#{ext}") + res = res.replace(///\.[^#{PATH_SEPERATOR_REGEXP_STRING}]*$///, ".#{ext}") res ###*