From 81b356713392c1b02b928b7512ba1ce78a3fdf95 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 24 Feb 2013 09:29:23 -0800 Subject: [PATCH] Add `path.sep` for older versions of Node.js. Former-commit-id: 1a058681fc5c6aae426902a7d6dd76b3a5849837 --- build.js | 8 +++++++- build/minify.js | 11 +++++++---- build/mkdirp-sync.js | 7 +++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/build.js b/build.js index 589159408..24044c199 100755 --- a/build.js +++ b/build.js @@ -12,6 +12,9 @@ minify = require(path.join(__dirname, 'build', 'minify.js')), mkdirpSync = require(path.join(__dirname, 'build', 'mkdirp-sync.js')); + /** Add `path.sep` for older versions of Node.js */ + path.sep || (path.sep = process.platform == 'win32' ? '\\' : '/'); + /** The current working directory */ var cwd = process.cwd(); @@ -22,7 +25,7 @@ var push = arrayRef.push; /** Used to detect the Node.js executable in command-line arguments */ - var reNode = /(?:^|[\/\\])node(?:\.exe)?$/; + var reNode = RegExp('(?:^|' + path.sep + ')node(?:\\.exe)?$'); /** Shortcut used to convert array-like objects to arrays */ var slice = arrayRef.slice; @@ -269,6 +272,9 @@ 'node' ]; + /** Add `path.sep` for older versions of Node.js */ + path.sep || (path.sep = process.platform == 'win32' ? '\\' : '/'); + /*--------------------------------------------------------------------------*/ /** diff --git a/build/minify.js b/build/minify.js index adb1c1ea1..b34a61c1f 100755 --- a/build/minify.js +++ b/build/minify.js @@ -16,6 +16,12 @@ postprocess = require('./post-compile.js'), tar = require('../vendor/tar/tar.js'); + /** Add `fs.existsSync` for older versions of Node.js */ + fs.existsSync || (fs.existsSync = path.existsSync); + + /** Add `path.sep` for older versions of Node.js */ + path.sep || (path.sep = process.platform == 'win32' ? '\\' : '/'); + /** The Git object ID of `closure-compiler.tar.gz` */ var closureId = '23cf67d0f0b979d97631fc108a2a43bb82225994'; @@ -41,7 +47,7 @@ var mediaType = 'application/vnd.github.v3.raw'; /** Used to detect the Node.js executable in command-line arguments */ - var reNode = /(?:^|[\/\\])node(?:\.exe)?$/; + var reNode = RegExp('(?:^|' + path.sep + ')node(?:\\.exe)?$'); /** Used to reference parts of the blob href */ var location = (function() { @@ -63,9 +69,6 @@ 'advanced': 'ADVANCED_OPTIMIZATIONS' }; - /** Reassign `existsSync` for older versions of Node.js */ - fs.existsSync || (fs.existsSync = path.existsSync); - /*--------------------------------------------------------------------------*/ /** diff --git a/build/mkdirp-sync.js b/build/mkdirp-sync.js index a40b0ea35..9bf1ee289 100755 --- a/build/mkdirp-sync.js +++ b/build/mkdirp-sync.js @@ -6,6 +6,11 @@ var fs = require('fs'), path = require('path'); + /** Add `path.sep` for older versions of Node.js */ + path.sep || (path.sep = process.platform == 'win32' ? '\\' : '/'); + + /*--------------------------------------------------------------------------*/ + /** * Makes the given `path` directory, without throwing errors for existing * directories and making parent directories as needed. @@ -36,6 +41,8 @@ }); } + /*--------------------------------------------------------------------------*/ + // expose module.exports = mkdirpSync; }());