Skip to content

Commit b0e8554

Browse files
committed
Migrate postinstall script to use modules
1 parent 03f99f5 commit b0e8554

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

extensions/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"typescript": "4.6.2"
88
},
99
"scripts": {
10-
"postinstall": "node ./postinstall"
10+
"postinstall": "node ./postinstall.mjs"
1111
},
1212
"devDependencies": {
1313
"esbuild": "^0.11.12",

extensions/postinstall.js renamed to extensions/postinstall.mjs

+5-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5-
// @ts-check
65

7-
'use strict';
6+
import * as fs from 'fs';
7+
import path from 'path';
8+
import { fileURLToPath } from 'url';
89

9-
const fs = require('fs');
10-
const path = require('path');
11-
const rimraf = require('rimraf');
12-
13-
const root = path.join(__dirname, 'node_modules', 'typescript');
10+
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), 'node_modules', 'typescript');
1411

1512
function processRoot() {
1613
const toKeep = new Set([
@@ -21,7 +18,7 @@ function processRoot() {
2118
if (!toKeep.has(name)) {
2219
const filePath = path.join(root, name);
2320
console.log(`Removed ${filePath}`);
24-
rimraf.sync(filePath);
21+
fs.rmSync(filePath, { recursive: true });
2522
}
2623
}
2724
}

0 commit comments

Comments
 (0)