Skip to content

Commit

Permalink
Relies on gpf.fs.read for command line hosts (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Oct 14, 2017
1 parent ddc1165 commit c73ca7f
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/require/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
*/
/*#ifndef(UMD)*/
"use strict";
/*global _GPF_FS_OPENFOR*/ // File system stream opening mode
/*global _GPF_HOST*/ // Host types
/*global _GPF_HTTP_METHODS*/ // HTTP Methods
/*global _GpfStreamWritableString*/ // gpf.stream.WritableString
/*global _gpfFileStorageByHost*/ // gpf.interfaces.IFileStorage per host
/*global _gpfFsRead*/ // Generic read method
/*global _gpfHost*/ // Host type
/*global _gpfHttpRequest*/ // HTTP request common implementation
/*global _gpfPathExtension*/ // Get the extension of the last name of a path (including dot)
Expand All @@ -32,22 +30,14 @@ function _gpfRequireLoadHTTP (name) {
}

function _gpfRequireLoadFS (name) {
var fs = _gpfFileStorageByHost[_gpfHost],
iWritableStream = new _GpfStreamWritableString();
if (name.charAt(0) === "/") {
// Must be relative to the current execution path
name = "." + name;
}
return fs.openTextStream(name, _GPF_FS_OPENFOR.READING)
.then(function (iReadStream) {
return iReadStream.read(iWritableStream);
})
.then(function () {
return iWritableStream.toString();
});
return _gpfFsRead(name);
}

if (_gpfHost === _GPF_HOST.BROWSER || _gpfHost === _GPF_HOST.PHANTOMJS) {
if (_gpfHost === _GPF_HOST.BROWSER) {
_gpfRequireLoadImpl = _gpfRequireLoadHTTP;
} else {
_gpfRequireLoadImpl = _gpfRequireLoadFS;
Expand Down

0 comments on commit c73ca7f

Please sign in to comment.