jscan 0.1.0 → 0.2.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jscan",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Code quality analyzer for JavaScript/TypeScript projects",
5
5
  "keywords": [
6
6
  "javascript",
@@ -37,8 +37,9 @@ const archiveName = `jscan_${version}_${platformName}_${archName}.tar.gz`;
37
37
  const downloadUrl = `https://github.com/ludo-technologies/jscan/releases/download/v${version}/${archiveName}`;
38
38
 
39
39
  const binDir = path.join(__dirname, "..", "bin");
40
+ const tempDir = path.join(__dirname, "..", ".tmp");
40
41
  const binaryPath = path.join(binDir, binaryName);
41
- const archivePath = path.join(binDir, archiveName);
42
+ const archivePath = path.join(tempDir, archiveName);
42
43
 
43
44
  // Skip download if binary already exists
44
45
  if (fs.existsSync(binaryPath)) {
@@ -46,10 +47,13 @@ if (fs.existsSync(binaryPath)) {
46
47
  process.exit(0);
47
48
  }
48
49
 
49
- // Create bin directory if it doesn't exist
50
+ // Create directories if they don't exist
50
51
  if (!fs.existsSync(binDir)) {
51
52
  fs.mkdirSync(binDir, { recursive: true });
52
53
  }
54
+ if (!fs.existsSync(tempDir)) {
55
+ fs.mkdirSync(tempDir, { recursive: true });
56
+ }
53
57
 
54
58
  console.log(`Downloading jscan v${version} for ${platformName}-${archName}...`);
55
59
  console.log(`URL: ${downloadUrl}`);
@@ -94,12 +98,12 @@ async function main() {
94
98
  await download(downloadUrl, archivePath);
95
99
  console.log("Download complete.");
96
100
 
97
- // Extract the archive
101
+ // Extract the archive to temp directory
98
102
  console.log("Extracting...");
99
- execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: "inherit" });
103
+ execSync(`tar -xzf "${archivePath}" -C "${tempDir}"`, { stdio: "inherit" });
100
104
 
101
- // Rename the binary
102
- const extractedBinary = path.join(binDir, `jscan${ext}`);
105
+ // Move binary to bin directory with platform-specific name
106
+ const extractedBinary = path.join(tempDir, `jscan${ext}`);
103
107
  if (fs.existsSync(extractedBinary)) {
104
108
  fs.renameSync(extractedBinary, binaryPath);
105
109
  }
@@ -109,8 +113,9 @@ async function main() {
109
113
  fs.chmodSync(binaryPath, 0o755);
110
114
  }
111
115
 
112
- // Clean up archive
116
+ // Clean up
113
117
  fs.unlinkSync(archivePath);
118
+ fs.rmdirSync(tempDir);
114
119
 
115
120
  console.log(`jscan v${version} installed successfully!`);
116
121
  } catch (error) {