From 63072934696184cef1377a0cda80c39981045ce9 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 31 Mar 2014 17:17:36 +0100 Subject: [PATCH] Fix some Node.js cross-platform compatibility issues Thanks to http://shapeshed.com/writing-cross-platform-node/ Surprising that file path format is pretty much the only issue. --- boot/boot.js | 8 ++++---- core/modules/commands/init.js | 2 +- plugins/tiddlywiki/filesystem/filesystemadaptor.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 25a72dc22..b25c639a6 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1316,7 +1316,7 @@ $tw.loadTiddlersFromPath = function(filepath,excludeRegExp) { // Look for a tiddlywiki.files file if(files.indexOf("tiddlywiki.files") !== -1) { // If so, process the files it describes - var filesInfo = JSON.parse(fs.readFileSync(filepath + "/tiddlywiki.files","utf8")); + var filesInfo = JSON.parse(fs.readFileSync(filepath + path.sep + "tiddlywiki.files","utf8")); $tw.utils.each(filesInfo.tiddlers,function(tidInfo) { var typeInfo = $tw.config.contentTypeInfo[tidInfo.fields.type || "text/plain"], pathname = path.resolve(filepath,tidInfo.file), @@ -1334,7 +1334,7 @@ $tw.loadTiddlersFromPath = function(filepath,excludeRegExp) { // If not, read all the files in the directory $tw.utils.each(files,function(file) { if(!excludeRegExp.test(file)) { - tiddlers.push.apply(tiddlers,$tw.loadTiddlersFromPath(filepath + "/" + file,excludeRegExp)); + tiddlers.push.apply(tiddlers,$tw.loadTiddlersFromPath(filepath + path.sep + file,excludeRegExp)); } }); } @@ -1355,13 +1355,13 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) { stat = fs.statSync(filepath); if(stat.isDirectory()) { // Read the plugin information - pluginInfo = JSON.parse(fs.readFileSync(filepath + "/plugin.info","utf8")); + pluginInfo = JSON.parse(fs.readFileSync(filepath + path.sep + "plugin.info","utf8")); // Read the plugin files files = fs.readdirSync(filepath); for(f=0; f