Skip to content

Commit

Permalink
sys:es: more lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Giannini authored and Matthew Giannini committed Nov 10, 2023
1 parent b1606fa commit d727f2d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/sys/es/fan/Env.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Env extends Obj {
this.#vars.caseInsensitive(true);
this.#props = Map.make(Str.type$, Str.type$);

const vars = ((typeof globalThis.fan$env) === 'undefined') ? {} : globalThis.fan$env;
const vars = ((typeof js.fan$env) === 'undefined') ? {} : js.fan$env;
this.__loadVars(vars);

this.#out = new ConsoleOutStream();
Expand All @@ -37,7 +37,7 @@ class Env extends Obj {
// set some pre-defined vars
if (Env.__isNode()) {
this.#vars.set("os.name", this.os());
this.#vars.set("os.version", Env.__node().os.version());
this.#vars.set("os.version", Env.__node()?.os?.version());
}

for (let i=0; i<keys.length; ++i) {
Expand Down Expand Up @@ -106,13 +106,13 @@ class Env extends Obj {
javaVersion() { return 0; }

os() {
let p = Env.__node().os.platform();
let p = Env.__node()?.os?.platform();
if (p === "darwin") p = "macosx";
return p;
}

arch() {
let a = Env.__node().os.arch();
let a = Env.__node()?.os?.arch();
switch (a) {
case "ia32": a = "x86";
case "x64": a = "x86_64";
Expand All @@ -139,7 +139,7 @@ class Env extends Obj {

diagnostics() { return Map.make(Str.type$, Obj.type$); }

host() { return Env.__node().os.hostname(); }
host() { return Env.__node()?.os?.hostname(); }

user() { return "unknown"; }

Expand All @@ -152,7 +152,7 @@ class Env extends Obj {

#win32prompt(msg) {
// https://github.com/nodejs/node/issues/28243
const fs = Env.__node().fs;
const fs = Env.__node()?.fs;
fs.writeSync(1, String(msg));
let s = '', buf = Buffer.alloc(1);
while(buf[0] != 10 && buf[0] != 13) {
Expand All @@ -165,7 +165,7 @@ class Env extends Obj {

#unixprompt(msg) {
// https://stackoverflow.com/questions/61394928/get-user-input-through-node-js-console/74250003?noredirect=1#answer-75008198
const fs = Env.__node().fs;
const fs = Env.__node()?.fs;
const stdin = fs.openSync("/dev/stdin","rs");

fs.writeSync(process.stdout.fd, msg);
Expand Down
6 changes: 3 additions & 3 deletions src/sys/es/fan/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class File extends Obj {
static os(osPath) {
if (!Env.__isNode())
throw Err.make("Must be running on Node JS to create a local file.");
const os = node.os;
if (os.platform() == "win32") {
const os = node.os;
if (os?.platform() == "win32") {
if (osPath.startsWith("/")) {
osPath = "file://" + osPath;
} else if (/^.+:/.test(osPath)) {
Expand All @@ -77,7 +77,7 @@ class File extends Obj {
static osRoots() {
if (!Env.__isNode())
throw Err.make("Must be running on Node JS to access the OS roots.");
const r = node.os.platform() == "win32"
const r = node.os?.platform() == "win32"
? "/" + File.__win32Drive() + "/"
: node.path.parse(process.cwd()).root;
return List.make(File.type$, [File.make(r, false)]);
Expand Down
2 changes: 1 addition & 1 deletion src/sys/es/fan/LocalFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LocalFile extends File {
// console.log("TODO: normalize windows path: " + instance.m_uri_str);
instance.#node_os_path = uri.toStr();

if (os.platform == "win32" && uri.isPathAbs()) {
if (os?.platform == "win32" && uri.isPathAbs()) {
let uriStr = uri.toStr();
if (!uri.isAbs()) {
// ensure the uri has file scheme
Expand Down
2 changes: 1 addition & 1 deletion src/sys/es/fan/ZipSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ class YazlZipFile {
// size of the central directory 8 bytes
yazl.writeUInt64LE(zip64EocdrBuffer, sizeOfCentralDirectory, 40);
// offset of start of central directory with respect to the starting disk number 8 bytes
writeUInt64LE(zip64EocdrBuffer, this.offsetOfStartOfCentralDirectory, 48);
yazl.writeUInt64LE(zip64EocdrBuffer, this.offsetOfStartOfCentralDirectory, 48);
// zip64 extensible data sector (variable size)
// nothing in the zip64 extensible data sector

Expand Down

0 comments on commit d727f2d

Please sign in to comment.