Skip to content

Commit

Permalink
fix: support windows platform
Browse files Browse the repository at this point in the history
  • Loading branch information
longkai committed Sep 30, 2022
1 parent f29ea73 commit f040250
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as process from 'child_process';
import { platform } from 'node:process';

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
Expand Down Expand Up @@ -38,7 +39,10 @@ export function activate(context: vscode.ExtensionContext) {
args.push(confFile);
}
// __dirname is `out`, so go back one level
const cmd = path.join(path.dirname(__dirname), 'bin', 'yamlfmt');
let cmd = path.join(path.dirname(__dirname), 'bin', 'yamlfmt');
if (platform === 'win32') {
cmd = path.join(path.dirname(__dirname), 'bin', 'yamlfmt.exe');
}
const sp = process.spawnSync(cmd, args, {
input: txt,
});
Expand Down

0 comments on commit f040250

Please sign in to comment.