Migrate postinstall script to use modules

pull/144136/head
Matt Bierner 2022-02-28 16:02:11 -08:00
parent 03f99f57c7
commit b0e8554cce
No known key found for this signature in database
GPG Key ID: 099C331567E11888
2 changed files with 6 additions and 9 deletions

View File

@ -7,7 +7,7 @@
"typescript": "4.6.2" "typescript": "4.6.2"
}, },
"scripts": { "scripts": {
"postinstall": "node ./postinstall" "postinstall": "node ./postinstall.mjs"
}, },
"devDependencies": { "devDependencies": {
"esbuild": "^0.11.12", "esbuild": "^0.11.12",

View File

@ -2,15 +2,12 @@
* Copyright (c) Microsoft Corporation. All rights reserved. * Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
// @ts-check
'use strict'; import * as fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const fs = require('fs'); const root = path.join(path.dirname(fileURLToPath(import.meta.url)), 'node_modules', 'typescript');
const path = require('path');
const rimraf = require('rimraf');
const root = path.join(__dirname, 'node_modules', 'typescript');
function processRoot() { function processRoot() {
const toKeep = new Set([ const toKeep = new Set([
@ -21,7 +18,7 @@ function processRoot() {
if (!toKeep.has(name)) { if (!toKeep.has(name)) {
const filePath = path.join(root, name); const filePath = path.join(root, name);
console.log(`Removed ${filePath}`); console.log(`Removed ${filePath}`);
rimraf.sync(filePath); fs.rmSync(filePath, { recursive: true });
} }
} }
} }