mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Added node.js version check and related refactorings
This commit is contained in:
parent
d53eb50a6e
commit
1f64a9e758
28
core/boot.js
28
core/boot.js
@ -39,6 +39,26 @@ if(typeof(window) === "undefined" && !global.$tw) {
|
||||
// Boot information
|
||||
$tw.boot = {};
|
||||
|
||||
// Server initialisation
|
||||
if(!$tw.browser) {
|
||||
// Standard node libraries
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
vm = require("vm");
|
||||
// System paths and filenames
|
||||
$tw.boot.bootFile = path.basename(module.filename);
|
||||
$tw.boot.bootPath = path.dirname(module.filename);
|
||||
$tw.boot.wikiPath = process.cwd();
|
||||
// Read package info
|
||||
$tw.packageInfo = JSON.parse(fs.readFileSync($tw.boot.bootPath + "/../package.json"));
|
||||
// Check node version number
|
||||
var targetVersion = $tw.packageInfo.engine.node.substr(2).split("."),
|
||||
currVersion = process.version.substr(1).split(".");
|
||||
if(targetVersion[0] > currVersion[0] || targetVersion[1] > currVersion[1] || targetVersion[2] > currVersion[2]) {
|
||||
throw "TiddlyWiki5 requires node.js version " + $tw.packageInfo.engine.node;
|
||||
}
|
||||
}
|
||||
|
||||
// Modules store registers all the modules the system has seen
|
||||
$tw.modules = $tw.modules || {};
|
||||
$tw.modules.titles = $tw.modules.titles || {}; // hashmap by module title of {fn:, exports:, moduleType:}
|
||||
@ -550,14 +570,6 @@ $tw.wiki.addTiddlers($tw.wiki.deserializeTiddlers("(DOM)",document.getElementByI
|
||||
|
||||
if(!$tw.browser) {
|
||||
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
vm = require("vm");
|
||||
|
||||
$tw.boot.bootFile = path.basename(module.filename);
|
||||
$tw.boot.bootPath = path.dirname(module.filename);
|
||||
$tw.boot.wikiPath = process.cwd();
|
||||
|
||||
/*
|
||||
Load the tiddlers contained in a particular file (and optionally the accompanying .meta file)
|
||||
*/
|
||||
|
@ -271,8 +271,7 @@ exports.extractVersionInfo = function() {
|
||||
|
||||
// Server version
|
||||
exports.extractVersionInfo = function() {
|
||||
var fs = require("fs");
|
||||
return JSON.parse(fs.readFileSync($tw.boot.bootPath + "/../package.json")).version;
|
||||
return $tw.packageInfo.version;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user