Migrate postinstall script to use modules

This commit is contained in:
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"
},
"scripts": {
"postinstall": "node ./postinstall"
"postinstall": "node ./postinstall.mjs"
},
"devDependencies": {
"esbuild": "^0.11.12",

View File

@ -2,15 +2,12 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* 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 path = require('path');
const rimraf = require('rimraf');
const root = path.join(__dirname, 'node_modules', 'typescript');
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), 'node_modules', 'typescript');
function processRoot() {
const toKeep = new Set([
@ -21,7 +18,7 @@ function processRoot() {
if (!toKeep.has(name)) {
const filePath = path.join(root, name);
console.log(`Removed ${filePath}`);
rimraf.sync(filePath);
fs.rmSync(filePath, { recursive: true });
}
}
}