From 4bc18372237110448e9fac7406fe76186acf6521 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 6 Jan 2012 17:28:40 -0800 Subject: [PATCH] support Windows XP by working around lack of symlink support with full copies - refs #1096 --- index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/index.js b/index.js index 3f98eeb5e..eacee44a0 100755 --- a/index.js +++ b/index.js @@ -1,12 +1,35 @@ #!/usr/bin/env node + +var fs = require('fs'); + process.title = 'tilemill'; // This is necessary to make optimist not special-case into coffeescript as // certain node installs (e.g. ubuntu node ppa) do not use `node` as the binary // name. process.argv[0] = 'node'; + if (process.platform === 'win32') { + + // HOME is undefined on windows process.env.HOME = process.env.HOMEPATH; + + // test for symlink support and fallback + // to full copying of files if lacking + try { + fs.symlinkSync('/tmp/from.txt','/tmp/to.txt'); + } catch (err) { + if (err.code === 'ENOTSUP') { + fs.symlink = function(from,to,cb) { + try { + fs_utils.cprSync(from,to); + return cb(); + } catch (err) { + return cb(err); + } + } + } + } } // Default --config flag to user's home .tilemill.json config file.