Skip to content

Commit

Permalink
Refactor post-install script to not depend on fs-extra (#5975)
Browse files Browse the repository at this point in the history
* Refactor post-install script to not depend on fs-extra
  • Loading branch information
kneth authored Jul 12, 2023
1 parent 1274da4 commit 783a329
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<!-- * Either mention core version or upgrade -->
<!-- * Using Realm Core vX.Y.Z -->
<!-- * Upgraded Realm Core from vX.Y.Z to vA.B.C -->
* Installation failed due to missing dependency (`fs-extra`), and the post-install script has been refactored to use `fs` instead.

## 12.0.0-rc.1 (2023-06-30)

Expand Down
12 changes: 6 additions & 6 deletions packages/realm/scripts/submit-analytics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import { createHmac } from "node:crypto";
import { Buffer } from "node:buffer";

import machineId from "node-machine-id";
import fse from "fs-extra";

import createDebug from "debug";
export const debug = createDebug("realm:submit-analytics");
Expand Down Expand Up @@ -104,8 +103,9 @@ function getProjectRoot() {
* @returns package.json as a JavaScript object
*/
function getPackageJson(packagePath) {
const packageJson = path.resolve(packagePath, "package.json");
return fse.readJsonSync(packageJson);
const packageJsonPath = path.resolve(packagePath, "package.json");
const packageJson = fs.readFileSync(packageJsonPath, "utf-8");
return JSON.parse(packageJson);
}

/**
Expand All @@ -127,8 +127,8 @@ function isAnalyticsDisabled() {
}

function getRealmVersion() {
const packageJsonPath = path.resolve(__dirname, "../package.json");
const packageJson = fse.readJsonSync(packageJsonPath);
const packageJsonPath = path.resolve(__dirname, "..", "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
return packageJson["version"];
}

Expand All @@ -139,7 +139,7 @@ function getRealmVersion() {
*/
function getRealmCoreVersion() {
const dependenciesListPath = path.resolve(__dirname, "../dependencies.list");
const dependenciesList = fse
const dependenciesList = fs
.readFileSync(dependenciesListPath)
.toString()
.split("\n")
Expand Down

0 comments on commit 783a329

Please sign in to comment.