diff --git a/lib/README.md b/lib/README.md index ef8f71d52..590c90247 100644 --- a/lib/README.md +++ b/lib/README.md @@ -144,23 +144,23 @@ During packaging process `pkg` collects project files and places them into executable. At run time the packaged application has internal virtual filesystem where all that files reside. -Packaged VFS files have `/thebox/` prefix in their paths (or -`C:\thebox\` in Windows). If you used `pkg /path/app.js` command line, -then `__filename` value will be likely `/thebox/path/app.js` -at run time. `__dirname` will be `/thebox/path` as well. Here is +Packaged VFS files have `/snapshot/` prefix in their paths (or +`C:\snapshot\` in Windows). If you used `pkg /path/app.js` command line, +then `__filename` value will be likely `/snapshot/path/app.js` +at run time. `__dirname` will be `/snapshot/path` as well. Here is the comparison table of path-related values: -value | with `node` | packaged | comments --------------------------------|---------------------|--------------------------|----------- -__filename | /project/app.js | /thebox/project/app.js | -__dirname | /project | /thebox/project | -process.cwd() | /project | /deploy | suppose the app is called ... -process.execPath | /usr/bin/nodejs | /deploy/app-x64 | `app-x64` and run in `/deploy` -process.argv[0] | /usr/bin/nodejs | /deploy/app-x64 | -process.argv[1] | /project/app.js | /deploy/app-x64 | -process.pkg.entrypoint | undefined | /thebox/project/app.js | -process.pkg.defaultEntrypoint | undefined | /thebox/project/app.js | -require.main.filename | /project/app.js | /thebox/project/app.js | +value | with `node` | packaged | comments +-------------------------------|---------------------|----------------------------|----------- +__filename | /project/app.js | /snapshot/project/app.js | +__dirname | /project | /snapshot/project | +process.cwd() | /project | /deploy | suppose the app is called ... +process.execPath | /usr/bin/nodejs | /deploy/app-x64 | `app-x64` and run in `/deploy` +process.argv[0] | /usr/bin/nodejs | /deploy/app-x64 | +process.argv[1] | /project/app.js | /deploy/app-x64 | +process.pkg.entrypoint | undefined | /snapshot/project/app.js | +process.pkg.defaultEntrypoint | undefined | /snapshot/project/app.js | +require.main.filename | /project/app.js | /snapshot/project/app.js | Hence in order to make use of the file collected at packaging time (pick up own JS plugin or serve an asset) you should take diff --git a/lib/packer.js b/lib/packer.js index 6082b0069..458e5260b 100644 --- a/lib/packer.js +++ b/lib/packer.js @@ -11,7 +11,7 @@ const STORE_STAT = common.STORE_STAT; const isDotJS = common.isDotJS; const isDotJSON = common.isDotJSON; -const theboxify = common.theboxify; +const snapshotify = common.snapshotify; const bootstrapText = fs.readFileSync( require.resolve('../prelude/bootstrap.js'), 'utf8' @@ -67,7 +67,7 @@ function packer (opts, cb) { if (!first1) write(','); first1 = false; - write(JSON.stringify(theboxify(file, opts.slash))); + write(JSON.stringify(snapshotify(file, opts.slash))); write(':[\n'); const record = records[file]; @@ -159,7 +159,7 @@ function packer (opts, cb) { opts.records.some(function (record) { if (record.entrypoint) { - write(JSON.stringify(theboxify(record.file, opts.slash))); + write(JSON.stringify(snapshotify(record.file, opts.slash))); return true; } diff --git a/prelude/bootstrap.js b/prelude/bootstrap.js index 64bb079f6..17bc33fa9 100644 --- a/prelude/bootstrap.js +++ b/prelude/bootstrap.js @@ -17,8 +17,8 @@ var STORE_LINKS = common.STORE_LINKS; var STORE_STAT = common.STORE_STAT; var normalizePath = common.normalizePath; -var insideTheBox = common.insideTheBox; -var stripTheBox = common.stripTheBox; +var insideSnapshot = common.insideSnapshot; +var stripSnapshot = common.stripSnapshot; var ENTRYPOINT; var FLAG_FORK_WAS_CALLED = false; @@ -34,7 +34,7 @@ if (ENTRYPOINT === 'DEFAULT_ENTRYPOINT') { ENTRYPOINT = DEFAULT_ENTRYPOINT; } -if (!insideTheBox(ENTRYPOINT)) { +if (!insideSnapshot(ENTRYPOINT)) { return { undoPatch: true }; } @@ -45,7 +45,7 @@ if (!insideTheBox(ENTRYPOINT)) { var mountpoints = []; function insideMountpoint (f) { - if (!insideTheBox(f)) return null; + if (!insideSnapshot(f)) return null; var file = normalizePath(f); var found = mountpoints.map(function (mountpoint) { var interior = mountpoint.interior; @@ -97,27 +97,27 @@ function createMountpoint (interior, exterior) { // TODO move to some test -createMountpoint("d:\\thebox\\countly\\plugins-ext", "d:\\deploy\\countly\\v16.02\\plugins-ext"); +createMountpoint("d:\\snapshot\\countly\\plugins-ext", "d:\\deploy\\countly\\v16.02\\plugins-ext"); -console.log(insideMountpoint("d:\\thebox")); -console.log(insideMountpoint("d:\\thebox\\")); -console.log(insideMountpoint("d:\\thebox\\countly")); -console.log(insideMountpoint("d:\\thebox\\countly\\")); -console.log(insideMountpoint("d:\\thebox\\countly\\plugins-ext")); -console.log(insideMountpoint("d:\\thebox\\countly\\plugins-ext\\")); -console.log(insideMountpoint("d:\\thebox\\countly\\plugins-ext\\1234")); +console.log(insideMountpoint("d:\\snapshot")); +console.log(insideMountpoint("d:\\snapshot\\")); +console.log(insideMountpoint("d:\\snapshot\\countly")); +console.log(insideMountpoint("d:\\snapshot\\countly\\")); +console.log(insideMountpoint("d:\\snapshot\\countly\\plugins-ext")); +console.log(insideMountpoint("d:\\snapshot\\countly\\plugins-ext\\")); +console.log(insideMountpoint("d:\\snapshot\\countly\\plugins-ext\\1234")); -console.log(translate("d:\\thebox\\countly\\plugins-ext")); -console.log(translate("d:\\thebox\\countly\\plugins-ext\\")); -console.log(translate("d:\\thebox\\countly\\plugins-ext\\1234")); +console.log(translate("d:\\snapshot\\countly\\plugins-ext")); +console.log(translate("d:\\snapshot\\countly\\plugins-ext\\")); +console.log(translate("d:\\snapshot\\countly\\plugins-ext\\1234")); -console.log(translateNth([], 0, "d:\\thebox\\countly\\plugins-ext")); -console.log(translateNth([], 0, "d:\\thebox\\countly\\plugins-ext\\")); -console.log(translateNth([], 0, "d:\\thebox\\countly\\plugins-ext\\1234")); +console.log(translateNth([], 0, "d:\\snapshot\\countly\\plugins-ext")); +console.log(translateNth([], 0, "d:\\snapshot\\countly\\plugins-ext\\")); +console.log(translateNth([], 0, "d:\\snapshot\\countly\\plugins-ext\\1234")); -console.log(translateNth(["", "r+"], 0, "d:\\thebox\\countly\\plugins-ext")); -console.log(translateNth(["", "rw"], 0, "d:\\thebox\\countly\\plugins-ext\\")); -console.log(translateNth(["", "a+"], 0, "d:\\thebox\\countly\\plugins-ext\\1234")); +console.log(translateNth(["", "r+"], 0, "d:\\snapshot\\countly\\plugins-ext")); +console.log(translateNth(["", "rw"], 0, "d:\\snapshot\\countly\\plugins-ext\\")); +console.log(translateNth(["", "a+"], 0, "d:\\snapshot\\countly\\plugins-ext\\1234")); */ // ///////////////////////////////////////////////////////////////// @@ -149,7 +149,7 @@ function projectToNearby (f) { } function findNativeAddon (path) { - if (!insideTheBox(path)) throw new Error('UNEXPECTED-10'); + if (!insideSnapshot(path)) throw new Error('UNEXPECTED-10'); if (path.slice(-5) !== '.node') return null; // leveldown.node.js var projector = projectToFilesystem(path); if (require('fs').existsSync(projector)) return projector; @@ -463,7 +463,7 @@ var modifyNativeAddonWin32 = (function () { function error_ENOENT (fileOrDirectory, path) { // eslint-disable-line camelcase var error = new Error( - fileOrDirectory + ' \'' + stripTheBox(path) + '\' ' + + fileOrDirectory + ' \'' + stripSnapshot(path) + '\' ' + 'was not included into executable at compilation stage. ' + 'Please recompile adding it as asset or script.' ); @@ -500,10 +500,10 @@ var modifyNativeAddonWin32 = (function () { // open ////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function openFromTheBox (path_) { + function openFromSnapshot (path_) { var path = normalizePath(path_); - // console.log("openFromTheBox", path); + // console.log("openFromSnapshot", path); var entity = VIRTUAL_FILESYSTEM[path]; if (!entity) throw error_ENOENT('File or directory', path); var nullDevice = windows ? '\\\\.\\NUL' : '/dev/null'; @@ -519,20 +519,20 @@ var modifyNativeAddonWin32 = (function () { fs.openSync = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.openSync.apply(fs, arguments); } if (insideMountpoint(path)) { return ancestor.openSync.apply(fs, translateNth(arguments, 0, path)); } - return openFromTheBox(path); + return openFromSnapshot(path); }; fs.open = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.open.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -541,7 +541,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = openFromTheBox(path); + var r = openFromSnapshot(path); process.nextTick(function () { callback(null, r); }); @@ -557,7 +557,7 @@ var modifyNativeAddonWin32 = (function () { // read ////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function readFromTheBoxSub (dock, entityContent, buffer, offset, length, position) { + function readFromSnapshotSub (dock, entityContent, buffer, offset, length, position) { var p = position; if ((p === null) || (typeof p === 'undefined')) p = dock.position; @@ -569,7 +569,7 @@ var modifyNativeAddonWin32 = (function () { } - function readFromTheBox (fd, buffer, offset, length, position) { + function readFromSnapshot (fd, buffer, offset, length, position) { if (offset < 0) throw new Error('Offset is out of bounds'); if ((offset >= buffer.length) && (NODE_VERSION_MAJOR >= 6)) return 0; @@ -579,7 +579,7 @@ var modifyNativeAddonWin32 = (function () { var dock = docks[fd]; var entity = dock.entity; var entityContent = entity[STORE_CONTENT]; - if (entityContent) return readFromTheBoxSub(dock, entityContent, buffer, offset, length, position); + if (entityContent) return readFromSnapshotSub(dock, entityContent, buffer, offset, length, position); var entityLinks = entity[STORE_LINKS]; if (entityLinks) throw error_EISDIR(dock.path); throw new Error('UNEXPECTED-15'); @@ -592,7 +592,7 @@ var modifyNativeAddonWin32 = (function () { return ancestor.readSync.apply(fs, arguments); } - return readFromTheBox(fd, buffer, offset, length, position); + return readFromSnapshot(fd, buffer, offset, length, position); }; @@ -604,7 +604,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = readFromTheBox( + var r = readFromSnapshot( fd, buffer, offset, length, position ); process.nextTick(function () { @@ -622,7 +622,7 @@ var modifyNativeAddonWin32 = (function () { // write ///////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function writeToTheBox () { + function writeToSnapshot () { throw new Error('Cannot write to packaged file'); @@ -634,7 +634,7 @@ var modifyNativeAddonWin32 = (function () { return ancestor.writeSync.apply(fs, arguments); } - return writeToTheBox(); + return writeToSnapshot(); }; @@ -646,7 +646,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = writeToTheBox(); + var r = writeToSnapshot(); process.nextTick(function () { callback(null, r, buffer); }); @@ -662,7 +662,7 @@ var modifyNativeAddonWin32 = (function () { // close ///////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function closeFromTheBox (fd) { + function closeFromSnapshot (fd) { ancestor.closeSync.call(fs, fd); delete docks[fd]; @@ -675,7 +675,7 @@ var modifyNativeAddonWin32 = (function () { return ancestor.closeSync.apply(fs, arguments); } - return closeFromTheBox(fd); + return closeFromSnapshot(fd); }; @@ -687,7 +687,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = closeFromTheBox(fd); + var r = closeFromSnapshot(fd); process.nextTick(function () { callback(null, r); }); @@ -713,10 +713,10 @@ var modifyNativeAddonWin32 = (function () { } } - function readFileFromTheBox (path_) { + function readFileFromSnapshot (path_) { var path = normalizePath(path_); - // console.log("readFileFromTheBox", path); + // console.log("readFileFromSnapshot", path); var entity = VIRTUAL_FILESYSTEM[path]; if (!entity) throw error_ENOENT('File', path); var entityCode = entity[STORE_CODE]; @@ -725,7 +725,7 @@ var modifyNativeAddonWin32 = (function () { // why return empty buffer? // otherwise this error will arise: // Error: UNEXPECTED-20 - // at readFileFromTheBox (e:0) + // at readFileFromSnapshot (e:0) // at Object.fs.readFileSync (e:0) // at Object.Module._extensions..js (module.js:421:20) // at Module.load (module.js:357:32) @@ -748,7 +748,7 @@ var modifyNativeAddonWin32 = (function () { return path; } - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.readFileSync.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -763,7 +763,7 @@ var modifyNativeAddonWin32 = (function () { var encoding = options.encoding; assertEncoding(encoding); - var buffer = readFileFromTheBox(path); + var buffer = readFileFromSnapshot(path); if (encoding) buffer = buffer.toString(encoding); return buffer; @@ -771,7 +771,7 @@ var modifyNativeAddonWin32 = (function () { fs.readFile = function (path, options_) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.readFile.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -789,7 +789,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var buffer = readFileFromTheBox(path); + var buffer = readFileFromSnapshot(path); if (encoding) buffer = buffer.toString(encoding); process.nextTick(function () { callback(null, buffer); @@ -813,10 +813,10 @@ var modifyNativeAddonWin32 = (function () { // readdir /////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function readdirFromTheBox (path_) { + function readdirFromSnapshot (path_) { var path = normalizePath(path_); - // console.log("readdirFromTheBox", path); + // console.log("readdirFromSnapshot", path); var entity = VIRTUAL_FILESYSTEM[path]; if (!entity) throw error_ENOENT('Directory', path); var entityLinks = entity[STORE_LINKS]; @@ -831,20 +831,20 @@ var modifyNativeAddonWin32 = (function () { fs.readdirSync = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.readdirSync.apply(fs, arguments); } if (insideMountpoint(path)) { return ancestor.readdirSync.apply(fs, translateNth(arguments, 0, path)); } - return readdirFromTheBox(path); + return readdirFromSnapshot(path); }; fs.readdir = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.readdir.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -853,7 +853,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = readdirFromTheBox(path); + var r = readdirFromSnapshot(path); process.nextTick(function () { callback(null, r); }); @@ -869,30 +869,30 @@ var modifyNativeAddonWin32 = (function () { // realpath ////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function realpathFromTheBox (path_) { + function realpathFromSnapshot (path_) { var path = normalizePath(path_); - // console.log("realpathFromTheBox", path); + // console.log("realpathFromSnapshot", path); return path; } fs.realpathSync = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.realpathSync.apply(fs, arguments); } if (insideMountpoint(path)) { // app should not know real file name } - return realpathFromTheBox(path); + return realpathFromSnapshot(path); }; fs.realpath = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.realpath.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -900,7 +900,7 @@ var modifyNativeAddonWin32 = (function () { } var callback = maybeCallback(arguments); - var r = realpathFromTheBox(path); + var r = realpathFromSnapshot(path); process.nextTick(function () { callback(null, r); }); @@ -947,10 +947,10 @@ var modifyNativeAddonWin32 = (function () { return ancestor.statSync.call(fs, path); } - function statFromTheBox (path_) { + function statFromSnapshot (path_) { var path = normalizePath(path_); - // console.log("statFromTheBox", path); + // console.log("statFromSnapshot", path); var entity = VIRTUAL_FILESYSTEM[path]; if (!entity) return findNativeAddonForStat(path); var entityStat = entity[STORE_STAT]; @@ -963,20 +963,20 @@ var modifyNativeAddonWin32 = (function () { fs.statSync = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.statSync.apply(fs, arguments); } if (insideMountpoint(path)) { return ancestor.statSync.apply(fs, translateNth(arguments, 0, path)); } - return statFromTheBox(path); + return statFromSnapshot(path); }; fs.stat = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.stat.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -985,7 +985,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = statFromTheBox(path); + var r = statFromSnapshot(path); process.nextTick(function () { callback(null, r); }); @@ -1003,20 +1003,20 @@ var modifyNativeAddonWin32 = (function () { fs.lstatSync = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.lstatSync.apply(fs, arguments); } if (insideMountpoint(path)) { return ancestor.lstatSync.apply(fs, translateNth(arguments, 0, path)); } - return statFromTheBox(path); + return statFromSnapshot(path); }; fs.lstat = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.lstat.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -1025,7 +1025,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = statFromTheBox(path); + var r = statFromSnapshot(path); process.nextTick(function () { callback(null, r); }); @@ -1041,7 +1041,7 @@ var modifyNativeAddonWin32 = (function () { // fstat ///////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function fstatFromTheBox (fd) { + function fstatFromSnapshot (fd) { var dock = docks[fd]; var entity = dock.entity; @@ -1059,7 +1059,7 @@ var modifyNativeAddonWin32 = (function () { return ancestor.fstatSync.apply(fs, arguments); } - return fstatFromTheBox(fd); + return fstatFromSnapshot(fd); }; @@ -1071,7 +1071,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = fstatFromTheBox(fd); + var r = fstatFromSnapshot(fd); process.nextTick(function () { callback(null, r); }); @@ -1087,10 +1087,10 @@ var modifyNativeAddonWin32 = (function () { // exists //////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function existsFromTheBox (path_) { + function existsFromSnapshot (path_) { var path = normalizePath(path_); - // console.log("existsFromTheBox", path); + // console.log("existsFromSnapshot", path); var entity = VIRTUAL_FILESYSTEM[path]; if (!entity) return false; return true; @@ -1099,20 +1099,20 @@ var modifyNativeAddonWin32 = (function () { fs.existsSync = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.existsSync.apply(fs, arguments); } if (insideMountpoint(path)) { return ancestor.existsSync.apply(fs, translateNth(arguments, 0, path)); } - return existsFromTheBox(path); + return existsFromSnapshot(path); }; fs.exists = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.exists.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -1120,7 +1120,7 @@ var modifyNativeAddonWin32 = (function () { } var callback = maybeCallback(arguments); - var r = existsFromTheBox(path); + var r = existsFromSnapshot(path); process.nextTick(function () { callback(r); }); @@ -1131,10 +1131,10 @@ var modifyNativeAddonWin32 = (function () { // access //////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////// - function accessFromTheBox (path_) { + function accessFromSnapshot (path_) { var path = normalizePath(path_); - // console.log("accessFromTheBox", path); + // console.log("accessFromSnapshot", path); var entity = VIRTUAL_FILESYSTEM[path]; if (!entity) throw error_ENOENT('File or directory', path); return undefined; @@ -1143,20 +1143,20 @@ var modifyNativeAddonWin32 = (function () { fs.accessSync = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.accessSync.apply(fs, arguments); } if (insideMountpoint(path)) { return ancestor.accessSync.apply(fs, translateNth(arguments, 0, path)); } - return accessFromTheBox(path); + return accessFromSnapshot(path); }; fs.access = function (path) { - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return ancestor.access.apply(fs, arguments); } if (insideMountpoint(path)) { @@ -1165,7 +1165,7 @@ var modifyNativeAddonWin32 = (function () { var callback = maybeCallback(arguments); try { - var r = accessFromTheBox(path); + var r = accessFromSnapshot(path); process.nextTick(function () { callback(null, r); }); @@ -1205,7 +1205,7 @@ var modifyNativeAddonWin32 = (function () { var path = revertMakingLong(long); - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return process.binding('fs').internalModuleStat(long); } if (insideMountpoint(path)) { @@ -1233,7 +1233,7 @@ var modifyNativeAddonWin32 = (function () { var path = revertMakingLong(long); - if (!insideTheBox(path)) { + if (!insideSnapshot(path)) { return process.binding('fs').internalModuleReadFile(long); } if (insideMountpoint(path)) { @@ -1272,7 +1272,7 @@ var modifyNativeAddonWin32 = (function () { } catch (error) { if (((error.code === 'ENOENT') || (error.code === 'MODULE_NOT_FOUND')) && - (!insideTheBox(path)) && + (!insideSnapshot(path)) && (!require('path').isAbsolute(path))) { if (!error.pkg) { error.pkg = true; @@ -1315,7 +1315,7 @@ var modifyNativeAddonWin32 = (function () { Module.prototype._compile = function (content, filename_) { - if (!insideTheBox(filename_)) { + if (!insideSnapshot(filename_)) { return ancestor._compile.apply(this, arguments); } if (insideMountpoint(filename_)) { @@ -1370,7 +1370,7 @@ var modifyNativeAddonWin32 = (function () { FLAG_DISABLE_DOT_NODE = false; } - if (!insideTheBox(filename)) { + if (!insideSnapshot(filename)) { return filename; } if (insideMountpoint(filename)) { @@ -1388,7 +1388,7 @@ var modifyNativeAddonWin32 = (function () { var filename = filename_; - if (!insideTheBox(filename)) { + if (!insideSnapshot(filename)) { try { return ancestor._node.call(null, module, filename); } catch (error) { @@ -1552,9 +1552,9 @@ var modifyNativeAddonWin32 = (function () { } var entrypoint = extractEntrypoint(args[1]); - if (callsNode && insideTheBox(entrypoint)) { + if (callsNode && insideSnapshot(entrypoint)) { // pm2 calls "node" with __dirname-based - // thebox-script. force execPath instead of "node" + // snapshot-script. force execPath instead of "node" args[0] = process.execPath; } @@ -1584,18 +1584,18 @@ var modifyNativeAddonWin32 = (function () { ])); assert(JSON.stringify(rearrange([ - "/thebox/home/igor/script.js" + "/snapshot/home/igor/script.js" ])) === JSON.stringify([ "--entrypoint", - "/thebox/home/igor/script.js" + "/snapshot/home/igor/script.js" ])); assert(JSON.stringify(rearrange([ "--node-opt-01", - "/thebox/home/igor/script.js" + "/snapshot/home/igor/script.js" ])) === JSON.stringify([ "--entrypoint", - "/thebox/home/igor/script.js", + "/snapshot/home/igor/script.js", "--runtime", "--node-opt-01" ])); @@ -1603,22 +1603,22 @@ var modifyNativeAddonWin32 = (function () { assert(JSON.stringify(rearrange([ "--node-opt-01", "--node-opt-02", - "/thebox/home/igor/script.js" + "/snapshot/home/igor/script.js" ])) === JSON.stringify([ "--entrypoint", - "/thebox/home/igor/script.js", + "/snapshot/home/igor/script.js", "--runtime", "--node-opt-01", "--node-opt-02" ])); assert(JSON.stringify(rearrange([ - "/thebox/home/igor/script.js", + "/snapshot/home/igor/script.js", "app-opt-01", "app-opt-02" ])) === JSON.stringify([ "--entrypoint", - "/thebox/home/igor/script.js", + "/snapshot/home/igor/script.js", "app-opt-01", "app-opt-02" ])); @@ -1626,12 +1626,12 @@ var modifyNativeAddonWin32 = (function () { assert(JSON.stringify(rearrange([ "--node-opt-01", "--node-opt-02", - "/thebox/home/igor/script.js", + "/snapshot/home/igor/script.js", "app-opt-01", "app-opt-02" ])) === JSON.stringify([ "--entrypoint", - "/thebox/home/igor/script.js", + "/snapshot/home/igor/script.js", "app-opt-01", "app-opt-02", "--runtime", diff --git a/prelude/common.js b/prelude/common.js index ec9e1feee..5d3cf9650 100644 --- a/prelude/common.js +++ b/prelude/common.js @@ -65,46 +65,46 @@ function replaceSlashes (file, slash) { return file; } -function insertTheBox (file) { +function injectSnapshot (file) { if (/^.:\\/.test(file)) { // C:\path\to - return file[0] + ':\\thebox' + file.slice(2); + return file[0] + ':\\snapshot' + file.slice(2); } else if (/^\//.test(file)) { // /home/user/project - return '/thebox' + file; + return '/snapshot' + file; } return file; } -exports.theboxify = function (file, slash) { +exports.snapshotify = function (file, slash) { var f = normalizePath(file); - return insertTheBox(replaceSlashes(f, slash)); + return injectSnapshot(replaceSlashes(f, slash)); }; -function insideTheBox (f) { +function insideSnapshot (f) { if (typeof f !== 'string') return false; var file = normalizePath(f); - return (/^.:\\thebox$/.test(file)) || - (/^.:\\thebox\\/.test(file)) || - (/^\/thebox$/.test(file)) || - (/^\/thebox\//.test(file)); + return (/^.:\\snapshot$/.test(file)) || + (/^.:\\snapshot\\/.test(file)) || + (/^\/snapshot$/.test(file)) || + (/^\/snapshot\//.test(file)); } -exports.insideTheBox = insideTheBox; +exports.insideSnapshot = insideSnapshot; -exports.stripTheBox = function (f) { +exports.stripSnapshot = function (f) { var file = normalizePath(f); - if (/^.:\\thebox$/.test(file)) { + if (/^.:\\snapshot$/.test(file)) { return file[0] + ':\\'; } - if (/^.:\\thebox\\/.test(file)) { + if (/^.:\\snapshot\\/.test(file)) { return file[0] + ':' + file.slice(9); } - if (/^\/thebox$/.test(file)) { + if (/^\/snapshot$/.test(file)) { return '/'; } - if (/^\/thebox\//.test(file)) { + if (/^\/snapshot\//.test(file)) { return file.slice(7); } return f; // not inside diff --git a/test/test-48-common/main.js b/test/test-48-common/main.js index c14efa847..4495b7099 100644 --- a/test/test-48-common/main.js +++ b/test/test-48-common/main.js @@ -9,81 +9,81 @@ const common = require('../../prelude/common.js'); if (process.platform === 'win32') { - assert.equal('c:', common.normalizePath('c:')); - assert.equal('C:\\', common.normalizePath('c:\\')); - assert.equal('C:\\', common.normalizePath('c:\\\\')); - assert.equal('C:\\thebox', common.normalizePath('c:\\thebox')); - assert.equal('C:\\theboxer', common.normalizePath('c:\\theboxer')); - assert.equal('C:\\thebox', common.normalizePath('c:\\thebox\\')); - assert.equal('C:\\theboxer', common.normalizePath('c:\\theboxer\\')); - assert.equal('C:\\thebox\\foo', common.normalizePath('c:\\thebox\\\\foo')); - assert.equal('C:\\thebox\\foo\\bar', common.normalizePath('c:\\thebox\\\\foo\\\\bar\\\\\\')); + assert.equal('c:', common.normalizePath('c:')); + assert.equal('C:\\', common.normalizePath('c:\\')); + assert.equal('C:\\', common.normalizePath('c:\\\\')); + assert.equal('C:\\snapshot', common.normalizePath('c:\\snapshot')); + assert.equal('C:\\snapshoter', common.normalizePath('c:\\snapshoter')); + assert.equal('C:\\snapshot', common.normalizePath('c:\\snapshot\\')); + assert.equal('C:\\snapshoter', common.normalizePath('c:\\snapshoter\\')); + assert.equal('C:\\snapshot\\foo', common.normalizePath('c:\\snapshot\\\\foo')); + assert.equal('C:\\snapshot\\foo\\bar', common.normalizePath('c:\\snapshot\\\\foo\\\\bar\\\\\\')); - assert.equal(common.insideTheBox('c:'), false); - assert.equal(common.insideTheBox('c:\\'), false); - assert.equal(common.insideTheBox('c:\\foo'), false); - assert.equal(common.insideTheBox('c:\\foo\\thebox'), false); - assert.equal(common.insideTheBox('c:\\thebox'), true); - assert.equal(common.insideTheBox('c:\\theboxer'), false); - assert.equal(common.insideTheBox('c:\\thebox\\'), true); - assert.equal(common.insideTheBox('c:\\theboxer\\'), false); - assert.equal(common.insideTheBox('c:\\thebox\\\\'), true); - assert.equal(common.insideTheBox('c:\\thebox\\foo'), true); - assert.equal(common.insideTheBox('c:\\theboxer\\foo'), false); + assert.equal(common.insideSnapshot('c:'), false); + assert.equal(common.insideSnapshot('c:\\'), false); + assert.equal(common.insideSnapshot('c:\\foo'), false); + assert.equal(common.insideSnapshot('c:\\foo\\snapshot'), false); + assert.equal(common.insideSnapshot('c:\\snapshot'), true); + assert.equal(common.insideSnapshot('c:\\snapshoter'), false); + assert.equal(common.insideSnapshot('c:\\snapshot\\'), true); + assert.equal(common.insideSnapshot('c:\\snapshoter\\'), false); + assert.equal(common.insideSnapshot('c:\\snapshot\\\\'), true); + assert.equal(common.insideSnapshot('c:\\snapshot\\foo'), true); + assert.equal(common.insideSnapshot('c:\\snapshoter\\foo'), false); - assert.equal('c:\\', common.stripTheBox('c:\\')); - assert.equal('c:\\\\', common.stripTheBox('c:\\\\')); - assert.equal('C:\\', common.stripTheBox('c:\\thebox')); - assert.equal('c:\\theboxer', common.stripTheBox('c:\\theboxer')); - assert.equal('C:\\', common.stripTheBox('c:\\thebox\\')); - assert.equal('c:\\theboxer\\', common.stripTheBox('c:\\theboxer\\')); - assert.equal('C:\\foo', common.stripTheBox('c:\\thebox\\\\foo')); - assert.equal('C:\\foo\\bar', common.stripTheBox('c:\\thebox\\\\foo\\\\bar\\\\\\')); + assert.equal('c:\\', common.stripSnapshot('c:\\')); + assert.equal('c:\\\\', common.stripSnapshot('c:\\\\')); + assert.equal('C:\\', common.stripSnapshot('c:\\snapshot')); + assert.equal('c:\\snapshoter', common.stripSnapshot('c:\\snapshoter')); + assert.equal('C:\\', common.stripSnapshot('c:\\snapshot\\')); + assert.equal('c:\\snapshoter\\', common.stripSnapshot('c:\\snapshoter\\')); + assert.equal('C:\\foo', common.stripSnapshot('c:\\snapshot\\\\foo')); + assert.equal('C:\\foo\\bar', common.stripSnapshot('c:\\snapshot\\\\foo\\\\bar\\\\\\')); - assert.equal('C:\\thebox\\', common.theboxify('c:\\')); - assert.equal('C:\\thebox\\foo', common.theboxify('c:\\foo')); - assert.equal('C:\\thebox\\foo', common.theboxify('c:\\foo\\')); - assert.equal('C:\\thebox\\foo', common.theboxify('c:\\foo\\\\')); - assert.equal('C:\\thebox\\foo\\bar', common.theboxify('c:\\foo\\\\bar')); - assert.equal('C:\\thebox\\foo\\bar', common.theboxify('c:\\foo\\\\bar\\\\\\')); + assert.equal('C:\\snapshot\\', common.snapshotify('c:\\')); + assert.equal('C:\\snapshot\\foo', common.snapshotify('c:\\foo')); + assert.equal('C:\\snapshot\\foo', common.snapshotify('c:\\foo\\')); + assert.equal('C:\\snapshot\\foo', common.snapshotify('c:\\foo\\\\')); + assert.equal('C:\\snapshot\\foo\\bar', common.snapshotify('c:\\foo\\\\bar')); + assert.equal('C:\\snapshot\\foo\\bar', common.snapshotify('c:\\foo\\\\bar\\\\\\')); } else { - assert.equal('/', common.normalizePath('/')); - assert.equal('/', common.normalizePath('//')); - assert.equal('/thebox', common.normalizePath('/thebox')); - assert.equal('/theboxer', common.normalizePath('/theboxer')); - assert.equal('/thebox', common.normalizePath('/thebox/')); - assert.equal('/theboxer', common.normalizePath('/theboxer/')); - assert.equal('/thebox/foo', common.normalizePath('/thebox//foo')); - assert.equal('/thebox/foo/bar', common.normalizePath('/thebox//foo//bar///')); + assert.equal('/', common.normalizePath('/')); + assert.equal('/', common.normalizePath('//')); + assert.equal('/snapshot', common.normalizePath('/snapshot')); + assert.equal('/snapshoter', common.normalizePath('/snapshoter')); + assert.equal('/snapshot', common.normalizePath('/snapshot/')); + assert.equal('/snapshoter', common.normalizePath('/snapshoter/')); + assert.equal('/snapshot/foo', common.normalizePath('/snapshot//foo')); + assert.equal('/snapshot/foo/bar', common.normalizePath('/snapshot//foo//bar///')); - assert.equal(common.insideTheBox(''), false); - assert.equal(common.insideTheBox('/'), false); - assert.equal(common.insideTheBox('/foo'), false); - assert.equal(common.insideTheBox('/foo/thebox'), false); - assert.equal(common.insideTheBox('/thebox'), true); - assert.equal(common.insideTheBox('/theboxer'), false); - assert.equal(common.insideTheBox('/thebox/'), true); - assert.equal(common.insideTheBox('/theboxer/'), false); - assert.equal(common.insideTheBox('/thebox//'), true); - assert.equal(common.insideTheBox('/thebox/foo'), true); - assert.equal(common.insideTheBox('/theboxer/foo'), false); + assert.equal(common.insideSnapshot(''), false); + assert.equal(common.insideSnapshot('/'), false); + assert.equal(common.insideSnapshot('/foo'), false); + assert.equal(common.insideSnapshot('/foo/snapshot'), false); + assert.equal(common.insideSnapshot('/snapshot'), true); + assert.equal(common.insideSnapshot('/snapshoter'), false); + assert.equal(common.insideSnapshot('/snapshot/'), true); + assert.equal(common.insideSnapshot('/snapshoter/'), false); + assert.equal(common.insideSnapshot('/snapshot//'), true); + assert.equal(common.insideSnapshot('/snapshot/foo'), true); + assert.equal(common.insideSnapshot('/snapshoter/foo'), false); - assert.equal('/', common.stripTheBox('/')); - assert.equal('//', common.stripTheBox('//')); - assert.equal('/', common.stripTheBox('/thebox')); - assert.equal('/theboxer', common.stripTheBox('/theboxer')); - assert.equal('/', common.stripTheBox('/thebox/')); - assert.equal('/theboxer/', common.stripTheBox('/theboxer/')); - assert.equal('/foo', common.stripTheBox('/thebox//foo')); - assert.equal('/foo/bar', common.stripTheBox('/thebox//foo//bar///')); + assert.equal('/', common.stripSnapshot('/')); + assert.equal('//', common.stripSnapshot('//')); + assert.equal('/', common.stripSnapshot('/snapshot')); + assert.equal('/snapshoter', common.stripSnapshot('/snapshoter')); + assert.equal('/', common.stripSnapshot('/snapshot/')); + assert.equal('/snapshoter/', common.stripSnapshot('/snapshoter/')); + assert.equal('/foo', common.stripSnapshot('/snapshot//foo')); + assert.equal('/foo/bar', common.stripSnapshot('/snapshot//foo//bar///')); - assert.equal('/thebox/', common.theboxify('/')); - assert.equal('/thebox/foo', common.theboxify('/foo')); - assert.equal('/thebox/foo', common.theboxify('/foo/')); - assert.equal('/thebox/foo', common.theboxify('/foo//')); - assert.equal('/thebox/foo/bar', common.theboxify('/foo//bar')); - assert.equal('/thebox/foo/bar', common.theboxify('/foo//bar///')); + assert.equal('/snapshot/', common.snapshotify('/')); + assert.equal('/snapshot/foo', common.snapshotify('/foo')); + assert.equal('/snapshot/foo', common.snapshotify('/foo/')); + assert.equal('/snapshot/foo', common.snapshotify('/foo//')); + assert.equal('/snapshot/foo/bar', common.snapshotify('/foo//bar')); + assert.equal('/snapshot/foo/bar', common.snapshotify('/foo//bar///')); } diff --git a/test/test-50-fs-runtime-layer-2/main.js b/test/test-50-fs-runtime-layer-2/main.js index c368ecf99..3065d9d42 100644 --- a/test/test-50-fs-runtime-layer-2/main.js +++ b/test/test-50-fs-runtime-layer-2/main.js @@ -13,7 +13,7 @@ const target = process.argv[2] || 'host'; const input = './test-x-index.js'; const output = './run-time/test-output.exe'; -// see readFromTheBox "NODE_VERSION_MAJOR" +// see readFromSnapshot "NODE_VERSION_MAJOR" function bitty (version) { return (2 * (/^(node|v)?4/.test(version))) | diff --git a/test/test-50-module-parent/main.js b/test/test-50-module-parent/main.js index 43c71268f..a6d6e0050 100644 --- a/test/test-50-module-parent/main.js +++ b/test/test-50-module-parent/main.js @@ -44,12 +44,12 @@ left.some(function (leftValue, index) { const rightValue = right[index]; if (leftValue.slice(1, 3) === ':\\') { assert.equal(rightValue.slice(1, 3), ':\\'); - leftValue = leftValue.slice(0, 3) + 'thebox\\' + leftValue.slice(3); + leftValue = leftValue.slice(0, 3) + 'snapshot\\' + leftValue.slice(3); assert.equal(leftValue, rightValue); } else if (leftValue.slice(0, 1) === '/') { assert.equal(rightValue.slice(0, 1), '/'); - leftValue = '/thebox' + leftValue; + leftValue = '/snapshot' + leftValue; assert.equal(leftValue, rightValue); } else { assert.equal(leftValue, rightValue); diff --git a/test/test-50-mountpoints/plugins-D-ext/test-y-require-D.js b/test/test-50-mountpoints/plugins-D-ext/test-y-require-D.js index b6e7d032b..33fa2f046 100644 --- a/test/test-50-mountpoints/plugins-D-ext/test-y-require-D.js +++ b/test/test-50-mountpoints/plugins-D-ext/test-y-require-D.js @@ -3,7 +3,7 @@ var assert = require('assert'); var common = require('../test-y-common.js'); -if (__dirname.indexOf('thebox') < 0) { +if (__dirname.indexOf('snapshot') < 0) { console.log(__dirname); assert(false); } diff --git a/test/test-50-require-main-parent/main.js b/test/test-50-require-main-parent/main.js index a5b19e850..0fef22d0b 100644 --- a/test/test-50-require-main-parent/main.js +++ b/test/test-50-require-main-parent/main.js @@ -46,12 +46,12 @@ left.some(function (leftValue, index) { const rightValue = right[index]; if (leftValue.slice(1, 3) === ':\\') { assert.equal(rightValue.slice(1, 3), ':\\'); - leftValue = leftValue.slice(0, 3) + 'thebox\\' + leftValue.slice(3); + leftValue = leftValue.slice(0, 3) + 'snapshot\\' + leftValue.slice(3); assert.equal(leftValue, rightValue); } else if (leftValue.slice(0, 1) === '/') { assert.equal(rightValue.slice(0, 1), '/'); - leftValue = '/thebox' + leftValue; + leftValue = '/snapshot' + leftValue; assert.equal(leftValue, rightValue); } else if (leftValue === '') {