Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove ESM "node:" import #329

Merged
merged 3 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/auto-approver/src/AutoApprover.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios, {AxiosError, AxiosInstance} from 'axios';
import logdown from 'logdown';
import {createRequire} from 'node:module';
import {createRequire} from 'module';

interface PackageJson {
bin: Record<string, string>;
Expand Down
4 changes: 2 additions & 2 deletions packages/auto-approver/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import {program as commander} from 'commander';
import {cosmiconfigSync} from 'cosmiconfig';
import logdown from 'logdown';
import readline from 'node:readline';
import {createRequire} from 'node:module';
import readline from 'readline';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {ApproverConfig, AutoApprover, Repository} from './AutoApprover.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/crates-updater/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import * as CratesUpdater from './CratesUpdater.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-icon-generator/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {IconGenerator} from './index.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-icon-generator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import * as fs from 'fs-extra';
import Jimp from 'jimp';
import path from 'node:path';
import {createRequire} from 'node:module';
import path from 'path';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);
const icongen = require('icon-gen');

Expand Down
4 changes: 2 additions & 2 deletions packages/electron-info/src/ElectronInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {expect, describe, test, beforeEach, beforeAll, afterAll, afterEach} from
import {StatusCodes as HTTP_STATUS} from 'http-status-codes';
import nock from 'nock';
import * as fs from 'fs-extra';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import path from 'path';
import {fileURLToPath} from 'url';
import {randomUUID} from 'crypto';

import {ElectronInfo, RawReleaseInfo} from './ElectronInfo.js';
Expand Down
6 changes: 3 additions & 3 deletions packages/electron-info/src/FileService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {isAfter as isAfterDate, sub as subtractDate} from 'date-fns';
import {constants as fsConstants, promises as fs} from 'node:fs';
import {constants as fsConstants, promises as fs} from 'fs';
import parseUrl from 'parse-url';
import logdown from 'logdown';
import os from 'node:os';
import path from 'node:path';
import os from 'os';
import path from 'path';

import type {Options, RawReleaseInfo} from './ElectronInfo.js';
import {HTTPService} from './HTTPService.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-info/src/HTTPService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {promises as fs} from 'node:fs';
import {inspect} from 'node:util';
import {promises as fs} from 'fs';
import {inspect} from 'util';
import axios from 'axios';
import logdown from 'logdown';

Expand Down
2 changes: 1 addition & 1 deletion packages/electron-info/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {ElectronInfo, RawDeps, SupportedDependencies} from './ElectronInfo.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/gh-open/src/RepositoryService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {promises as fsAsync} from 'node:fs';
import path from 'node:path';
import {promises as fsAsync} from 'fs';
import path from 'path';
import logdown from 'logdown';

import {GitHubClient} from './GitHubClient.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/gh-open/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env node

import path from 'node:path';
import path from 'path';
import {program as commander} from 'commander';
import {findUp} from 'find-up';
import open from 'open';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {RepositoryService} from './RepositoryService.js';
Expand Down
6 changes: 3 additions & 3 deletions packages/https-proxy/src/HttpsProxy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import basicAuth from 'basic-auth';
import http from 'node:http';
import http from 'http';
import logdown from 'logdown';
import net from 'node:net';
import net from 'net';
import compare from 'tsscmp';
import url from 'node:url';
import url from 'url';
import {StatusCodes as HTTP_STATUS} from 'http-status-codes';

export interface Options {
Expand Down
2 changes: 1 addition & 1 deletion packages/https-proxy/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {HttpsProxy} from './HttpsProxy.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/jszip-cli/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"esModuleInterop": true,
"outDir": "dist/cjs",
"rootDir": "src",
"moduleResolution": "NodeNext",
"module": "NodeNext"
"moduleResolution": "Node",
"module": "ESNext"
},
"exclude": ["dist", "node_modules", "src/*.test.ts"],
"extends": "../../tsconfig.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/mock-udp/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-magic-numbers */

import {assert, expect, describe, test, beforeEach} from 'vitest';
import * as dgram from 'node:dgram';
import * as dgram from 'dgram';
import * as mockudp from './index.js';
const buffer = Buffer.from('hello world');

Expand Down
2 changes: 1 addition & 1 deletion packages/mock-udp/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Socket} from 'node:dgram';
import {Socket} from 'dgram';

type SendCallback = (error: Error | null, bytes: number) => void;

Expand Down
2 changes: 1 addition & 1 deletion packages/my-timezone/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {MyTimezone} from './MyTimezone.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/ntfy/src/NtfyClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios, {AxiosHeaders, AxiosRequestConfig} from 'axios';
import {URL} from 'node:url';
import {promises as fs} from 'node:fs';
import {URL} from 'url';
import {promises as fs} from 'fs';
import type {
AttachmentConfig,
BroadcastAction,
Expand Down
2 changes: 1 addition & 1 deletion packages/ntpclient/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {NTPClient} from './index.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/pixelflut/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dgram from 'node:dgram';
import net from 'node:net';
import dgram from 'dgram';
import net from 'net';

export class Pixelflut {
public errors: string[] = [];
Expand Down
6 changes: 3 additions & 3 deletions packages/publish-flat/src/PublishFlat.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {execSync} from 'node:child_process';
import {execSync} from 'child_process';
import Arborist from '@npmcli/arborist';
import fs from 'fs-extra';
import logdown from 'logdown';
import packlist from 'npm-packlist';
import os from 'node:os';
import path from 'node:path';
import os from 'os';
import path from 'path';

interface PackageJson {
bin: Record<string, string> | string;
Expand Down
2 changes: 1 addition & 1 deletion packages/publish-flat/src/cli-copy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {copyJson} from './copyJson.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/publish-flat/src/copyJson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs-extra';
import path from 'node:path';
import path from 'path';

async function checkFile(filePath: string): Promise<void> {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/scrabble-cheater/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {createRequire} from 'node:module';
import {createRequire} from 'module';
const require = createRequire(import.meta.url);

import {Options, ScrabbleCheater} from './index.js';
Expand Down
6 changes: 3 additions & 3 deletions packages/scrabble-cheater/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import clipboard from 'clipboardy';
import fs from 'node:fs';
import readline from 'node:readline';
import {promisify} from 'node:util';
import fs from 'fs';
import readline from 'readline';
import {promisify} from 'util';
const readFileAsync = promisify(fs.readFile);

export interface Options {
Expand Down
4 changes: 2 additions & 2 deletions packages/which-os/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node

import {program as commander} from 'commander';
import {inspect} from 'node:util';
import fs from 'node:fs';
import {inspect} from 'util';
import fs from 'fs';

import * as whichOS from './which-os.js';

Expand Down
4 changes: 2 additions & 2 deletions packages/which-os/src/which-os.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os from 'node:os';
import process from 'node:process';
import os from 'os';
import process from 'process';

const platform = os.platform();

Expand Down
6 changes: 3 additions & 3 deletions packages/windows-shortcut-maker/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {spawn, spawnSync} from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import {spawn, spawnSync} from 'child_process';
import fs from 'fs';
import path from 'path';

export interface ShortcutOptions {
/** the absolute path including the name of which file should the module make a shortcut (required). */
Expand Down