mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-13 05:47:17 +00:00
Added node.js version check and related refactorings
This commit is contained in:
28
core/boot.js
28
core/boot.js
@@ -39,6 +39,26 @@ if(typeof(window) === "undefined" && !global.$tw) {
|
|||||||
// Boot information
|
// Boot information
|
||||||
$tw.boot = {};
|
$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
|
// Modules store registers all the modules the system has seen
|
||||||
$tw.modules = $tw.modules || {};
|
$tw.modules = $tw.modules || {};
|
||||||
$tw.modules.titles = $tw.modules.titles || {}; // hashmap by module title of {fn:, exports:, moduleType:}
|
$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) {
|
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)
|
Load the tiddlers contained in a particular file (and optionally the accompanying .meta file)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -271,8 +271,7 @@ exports.extractVersionInfo = function() {
|
|||||||
|
|
||||||
// Server version
|
// Server version
|
||||||
exports.extractVersionInfo = function() {
|
exports.extractVersionInfo = function() {
|
||||||
var fs = require("fs");
|
return $tw.packageInfo.version;
|
||||||
return JSON.parse(fs.readFileSync($tw.boot.bootPath + "/../package.json")).version;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user