Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump node to v12.18.3 (master) #24707

Merged
merged 5 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ vars = {
'chromium_version':
'93a6ebbe22f1a093e6a0cb5e72ba78990fe39824',
'node_version':
'v12.18.2',
'v12.18.3',
'nan_version':
'2c4ee8a32a299eada3cd6e468bbd0a473bfea96d',
'squirrel.mac_version':
Expand Down
11 changes: 6 additions & 5 deletions lib/asar/fs-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,23 +675,24 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
const { asarPath, filePath } = pathInfo;

const archive = getOrCreateArchive(asarPath);
if (!archive) return;
if (!archive) return [];

const info = archive.getFileInfo(filePath);
if (!info) return;
if (info.size === 0) return '';
if (!info) return [];
if (info.size === 0) return ['', false];
if (info.unpacked) {
const realPath = archive.copyFileOut(filePath);
return fs.readFileSync(realPath, { encoding: 'utf8' });
}

const buffer = Buffer.alloc(info.size);
const fd = archive.getFd();
if (!(fd >= 0)) return;
if (!(fd >= 0)) return [];

logASARAccess(asarPath, filePath, info.offset);
fs.readSync(fd, buffer, 0, info.size, info.offset);
return buffer.toString('utf8');
const str = buffer.toString('utf8');
return [str, str.length > 0];
};

const { internalModuleStat } = internalBinding('fs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loade
index 92554a374d189b3b284546b0e122940e9a175de8..e478c57af873da717c00db73d6719f806280efe1 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -55,10 +55,7 @@ const assert = require('internal/assert');
@@ -55,7 +55,7 @@ const assert = require('internal/assert');
const fs = require('fs');
const internalFS = require('internal/fs/utils');
const path = require('path');
-const {
- internalModuleReadJSON,
- internalModuleStat
-} = internalBinding('fs');
-const { internalModuleStat } = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
const packageJsonReader = require('internal/modules/package_json_reader');
const { safeGetenv } = internalBinding('credentials');
const {
makeRequireFunction,
@@ -144,14 +141,12 @@ function enrichCJSError(err) {
}

Expand All @@ -53,12 +50,26 @@ index 92554a374d189b3b284546b0e122940e9a175de8..e478c57af873da717c00db73d6719f80
if (statCache !== null) statCache.set(filename, result);
return result;
}
@@ -257,7 +252,7 @@ function readPackage(requestPath) {
const existing = packageJsonCache.get(jsonPath);
if (existing !== undefined) return existing;
diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js
index 066047b55eb9d82bc1eea66dc54aa68abd116b6b..4fcc65e235692d7d5fe2643571f006c593c4e173 100644
--- a/lib/internal/modules/package_json_reader.js
+++ b/lib/internal/modules/package_json_reader.js
@@ -1,7 +1,7 @@
'use strict';

- const json = internalModuleReadJSON(path.toNamespacedPath(jsonPath));
+ const json = internalFsBinding.internalModuleReadJSON(path.toNamespacedPath(jsonPath));
if (json === undefined) {
packageJsonCache.set(jsonPath, false);
return false;
const { SafeMap } = primordials;
-const { internalModuleReadJSON } = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved

const cache = new SafeMap();

@@ -14,7 +14,7 @@ function read(path) {
return cache.get(path);
}

- const [string, containsKeys] = internalModuleReadJSON(path);
+ const [string, containsKeys] = internalFsBinding.internalModuleReadJSON(path);
const result = { string, containsKeys };
cache.set(path, result);
return result;

15 changes: 10 additions & 5 deletions spec/asar-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1426,15 +1426,20 @@ describe('asar package', function () {
});

describe('internalModuleReadJSON', function () {
const internalModuleReadJSON = process.binding('fs').internalModuleReadJSON;
const { internalModuleReadJSON } = process.binding('fs');

it('read a normal file', function () {
it('reads a normal file', function () {
const file1 = path.join(asarDir, 'a.asar', 'file1');
expect(internalModuleReadJSON(file1).toString().trim()).to.equal('file1');
const [s1, c1] = internalModuleReadJSON(file1);
expect([s1.toString().trim(), c1]).to.eql(['file1', true]);

const file2 = path.join(asarDir, 'a.asar', 'file2');
expect(internalModuleReadJSON(file2).toString().trim()).to.equal('file2');
const [s2, c2] = internalModuleReadJSON(file2);
expect([s2.toString().trim(), c2]).to.eql(['file2', true]);

const file3 = path.join(asarDir, 'a.asar', 'file3');
expect(internalModuleReadJSON(file3).toString().trim()).to.equal('file3');
const [s3, c3] = internalModuleReadJSON(file3);
expect([s3.toString().trim(), c3]).to.eql(['file3', true]);
});

it('reads a normal file with unpacked files', function () {
Expand Down