mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
currentApp old code restored
This commit is contained in:
@ -1,5 +1,4 @@
|
|||||||
import file_access_module = require("file-system/file-system-access");
|
import file_access_module = require("file-system/file-system-access");
|
||||||
import * as utilsModule from "utils/utils";
|
|
||||||
|
|
||||||
// The FileSystemAccess implementation, used through all the APIs.
|
// The FileSystemAccess implementation, used through all the APIs.
|
||||||
var fileAccess;
|
var fileAccess;
|
||||||
@ -228,7 +227,7 @@ export class File extends FileSystemEntity {
|
|||||||
onError(error);
|
onError(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getFileAccess().write(this.path, content, localError);
|
getFileAccess().write(this.path, content, localError);
|
||||||
} finally {
|
} finally {
|
||||||
this[fileLockedProperty] = false;
|
this[fileLockedProperty] = false;
|
||||||
@ -263,7 +262,7 @@ export class File extends FileSystemEntity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var content = getFileAccess().readText(this.path, localError, encoding);
|
var content = getFileAccess().readText(this.path, localError, encoding);
|
||||||
this[fileLockedProperty] = false;
|
this[fileLockedProperty] = false;
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
@ -289,7 +288,7 @@ export class File extends FileSystemEntity {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
this[fileLockedProperty] = true;
|
this[fileLockedProperty] = true;
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
var localError = function (error) {
|
var localError = function (error) {
|
||||||
that[fileLockedProperty] = false;
|
that[fileLockedProperty] = false;
|
||||||
@ -484,9 +483,17 @@ export module knownFolders {
|
|||||||
|
|
||||||
export var currentApp = function (): Folder {
|
export var currentApp = function (): Folder {
|
||||||
if (!_app) {
|
if (!_app) {
|
||||||
var logicalRoot = getFileAccess().getLogicalRootPath();
|
const currentDir = __dirname;
|
||||||
|
const tnsModulesIndex = currentDir.indexOf("/tns_modules");
|
||||||
|
|
||||||
|
// Module not hosted in ~/tns_modules when bundled. Use current dir.
|
||||||
|
let appPath = currentDir;
|
||||||
|
if (tnsModulesIndex !== -1) {
|
||||||
|
// Strip part after tns_modules to obtain app root
|
||||||
|
appPath = currentDir.substring(0, tnsModulesIndex);
|
||||||
|
}
|
||||||
_app = new Folder();
|
_app = new Folder();
|
||||||
_app[pathProperty] = logicalRoot + "/app";
|
_app[pathProperty] = appPath;
|
||||||
_app[isKnownProperty] = true;
|
_app[isKnownProperty] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user