Skip to content

Commit 33caa66

Browse files
hardfistCopilot
andauthored
fix: try fix windows extension (#189)
Co-authored-by: Copilot <[email protected]>
1 parent a6dc46d commit 33caa66

File tree

5 files changed

+76
-14
lines changed

5 files changed

+76
-14
lines changed

.github/actions/move-artifacts/action.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,4 @@ runs:
77
- name: Move artifacts
88
shell: bash
99
run: |
10-
find ./binaries
11-
for file in binaries/*/*-rslint; do
12-
echo "Processing $file"
13-
filename=$(basename "$file")
14-
dirname="${filename%-rslint}"
15-
target_dir="npm/$dirname"
16-
mkdir -p "$target_dir"
17-
echo "Copy $file to $target_dir/rslint"
18-
cp "$file" "npm/$dirname/rslint"
19-
done
20-
find ./npm
10+
node .github/actions/move-artifacts/move-artifacts.js
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
6+
function findRslintBinaries(dir = 'binaries') {
7+
const files = [];
8+
9+
if (!fs.existsSync(dir)) {
10+
return files;
11+
}
12+
13+
const entries = fs.readdirSync(dir, { withFileTypes: true });
14+
15+
for (const entry of entries) {
16+
const fullPath = path.join(dir, entry.name);
17+
18+
if (entry.isDirectory()) {
19+
// Look for files ending with -rslint in subdirectories
20+
const subEntries = fs.readdirSync(fullPath, { withFileTypes: true });
21+
for (const subEntry of subEntries) {
22+
if (subEntry.isFile() && subEntry.name.endsWith('-rslint')) {
23+
files.push(path.join(fullPath, subEntry.name));
24+
}
25+
}
26+
}
27+
}
28+
29+
return files;
30+
}
31+
32+
async function moveArtifacts() {
33+
console.log('Starting artifact move process...');
34+
35+
try {
36+
// Find all rslint binary files
37+
const files = findRslintBinaries();
38+
console.log(`Found ${files.length} rslint binary files`);
39+
40+
for (const file of files) {
41+
console.log(`Processing ${file}`);
42+
const isWindows = file.includes('win32');
43+
const filename = path.basename(file);
44+
const dirname = filename.replace(/-rslint$/, '');
45+
const targetDir = path.join('npm', dirname);
46+
47+
const targetFile = path.join(
48+
targetDir,
49+
isWindows ? 'rslint.exe' : 'rslint',
50+
);
51+
52+
// Create target directory and copy file
53+
fs.mkdirSync(targetDir, { recursive: true });
54+
fs.copyFileSync(file, targetFile);
55+
fs.chmodSync(targetFile, 0o755); // Make executable
56+
57+
console.log(`Copied ${file} to ${targetFile}`);
58+
}
59+
60+
console.log('Artifact move process completed successfully!');
61+
} catch (error) {
62+
console.error('Error:', error.message);
63+
process.exit(1);
64+
}
65+
}
66+
67+
moveArtifacts();

packages/rslint/bin/rslint.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ function getBinPath() {
66
if (fs.existsSync(path.resolve(__dirname, './rslint'))) {
77
return path.resolve(__dirname, './rslint');
88
}
9+
if (fs.existsSync(path.resolve(__dirname, './rslint.exe'))) {
10+
return path.resolve(__dirname, './rslint.exe');
11+
}
912
let platformKey = `${process.platform}-${os.arch()}`;
1013

1114
return require.resolve(`@rslint/${platformKey}/rslint`);

packages/vscode-extension/src/Rslint.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class Rslint implements Disposable {
3232

3333
const binPath = await this.getBinaryPath();
3434
this.logger.info('Rslint binary path:', binPath);
35-
chmodSync(binPath, 0o755);
3635

3736
const run: Executable = {
3837
command: binPath,

scripts/publish-marketplace.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ async function publish_all() {
3232

3333
await $`rm -rf ./packages/vscode-extension/dist/rslint`;
3434
await $`rm -rf ./packages/vscode-extension/dist/rslint.exe`;
35-
await $`cp binaries/${os}-${arch}-rslint/${os}-${arch}-rslint ./packages/vscode-extension/dist/rslint`;
36-
await $`chmod +x ./packages/vscode-extension/dist/rslint`;
35+
const targetFilename = os == 'win32' ? 'rslint.exe' : 'rslint';
36+
await $`cp binaries/${os}-${arch}-rslint/${os}-${arch}-rslint ./packages/vscode-extension/dist/${targetFilename}`;
37+
38+
await $`chmod +x ./packages/vscode-extension/dist/${targetFilename}`;
39+
3740
await $`ls -lR ./packages/vscode-extension/dist`;
3841
const prereleaseFlag = prerelease ? ['--pre-release'] : [];
3942

0 commit comments

Comments
 (0)