Skip to content

Commit

Permalink
[update] add windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
keyhr committed Aug 15, 2022
1 parent 53738c7 commit 32d905a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "42-c-format",
"displayName": "42 C-Format",
"description": "VScode extension for c_formatter_42, which is a c-language formatter conforms to Norm v3 in 42 schools.",
"version": "0.0.4",
"version": "0.0.5",
"publisher": "keyhr",
"icon": "images/icon.png",
"repository": {
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as vscode from 'vscode';
import * as cp from 'child_process';
import * as os from 'node:os';
import { openStdin } from 'process';

export let outputChannel = vscode.window.createOutputChannel('42-c-format');

Expand Down Expand Up @@ -32,7 +34,7 @@ class DocumntFormattingEditProvider implements vscode.DocumentFormattingEditProv

let stdout = '';
let stderr = '';
let child = cp.spawn('python3', ['-m', 'c_formatter_42'], { cwd: vscode.workspace.rootPath });
let child = cp.spawn((os.platform() === 'win32') ? 'python' : 'python3', ['-m', 'c_formatter_42'], { cwd: vscode.workspace.rootPath });
child.stdin.end(textContent);
child.stdout.on('data', chunk => stdout += chunk);
child.stderr.on('data', chunk => stderr += chunk);
Expand Down

0 comments on commit 32d905a

Please sign in to comment.