Skip to content

Commit ad2d348

Browse files
committed
fix postinstall.js to not override pythagora api key
1 parent 3761808 commit ad2d348

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pythagora",
3-
"version": "0.0.73",
3+
"version": "0.0.76",
44
"author": {
55
"name": "Zvonimir Sabljic",
66
"email": "[email protected]"

src/bin/postinstall.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ const hash = crypto.createHash('sha256');
1515
hash.update(installationDirectory);
1616
const pathId = hash.digest('hex');
1717

18-
// Try to read the config file and get the userId
19-
let userId;
18+
let config;
2019
try {
21-
const config = JSON.parse(fs.readFileSync(configPath));
22-
userId = config.userId;
20+
config = JSON.parse(fs.readFileSync(configPath));
2321
} catch (err) {
2422
// Config file doesn't exist or is not valid JSON
2523
}
2624

25+
if (!config) config = {};
26+
2727
// If there's no userId, generate one and save it to the config file
28-
if (!userId) {
29-
userId = uuidv4();
28+
if (!config.userId) {
29+
config.userId = uuidv4();
3030
const configDir = path.dirname(configPath);
3131
if (!fs.existsSync(configDir)) {
3232
fs.mkdirSync(configDir, { recursive: true });
3333
}
34-
fs.writeFileSync(configPath, JSON.stringify({ userId }, null, 2));
34+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
3535
}
3636

3737
// Send the request to the telemetry endpoint
3838
const telemetryData = {
39-
userId,
39+
userId: config.userId,
4040
pathId,
4141
event: 'install',
4242
pythagoraVersion

0 commit comments

Comments
 (0)