Skip to content

Commit

Permalink
fix(scripts/bundle): dont bundle types
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Aug 9, 2022
1 parent 489c608 commit a957a03
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 66 deletions.
6 changes: 3 additions & 3 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Type definitions for bun-utilities
// Project: https://github.com/xHyroM/bun-utilities

/// <reference path="./utils/fs.d.ts" />
/// <reference path="./utils/os.d.ts" />
/// <reference path="./utils/spawn.d.ts" />
export * from './utils/fs';
export * from './utils/os';
export * from './utils/spawn';
24 changes: 11 additions & 13 deletions lib/utils/fs.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
declare module 'bun-utilities/fs' {
export interface RecrusiveOptions {
recursive?: boolean;
}

export interface CopyDirOptions {
recursive?: boolean;
copyFiles?: boolean;
}
export interface RecrusiveOptions {
recursive?: boolean;
}

export function rmdir(path: string, options?: RecrusiveOptions | undefined | null): string;
export function copyfile(src: string, dest: string, options?: RecrusiveOptions | undefined | null): string;
export function copydir(src: string, dest: string, options?: CopyDirOptions | undefined | null): string;
}
export interface CopyDirOptions {
recursive?: boolean;
copyFiles?: boolean;
}

export function rmdir(path: string, options?: RecrusiveOptions | undefined | null): string;
export function copyfile(src: string, dest: string, options?: RecrusiveOptions | undefined | null): string;
export function copydir(src: string, dest: string, options?: CopyDirOptions | undefined | null): string;
52 changes: 25 additions & 27 deletions lib/utils/os.d.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
declare module 'bun-utilities/os' {
export function homedir(): string | null;
export function cachedir(): string | null;
export function tempdir(): string;
export function hostname(): string | null;
export function platform(): string;
export function arch(): string;
export function release(): string | null;
export function uptime(): number | null;
export interface CpuInfo {
model: string;
speed: number;
usage: number;
ventorId: string;
}
export function cpus(): Array<CpuInfo>;
export function totalMemory(): number;
export function freeMemory(): number;
export function totalSwap(): number;
export function freeSwap(): number;
export interface NetworkInfo {
name: string;
address: string;
netmask?: string;
family: 'IPv4' | 'IPv6';
}
export function networkInterfaces(): Array<NetworkInfo>;
export function homedir(): string | null;
export function cachedir(): string | null;
export function tempdir(): string;
export function hostname(): string | null;
export function platform(): string;
export function arch(): string;
export function release(): string | null;
export function uptime(): number | null;
export interface CpuInfo {
model: string;
speed: number;
usage: number;
ventorId: string;
}
export function cpus(): Array<CpuInfo>;
export function totalMemory(): number;
export function freeMemory(): number;
export function totalSwap(): number;
export function freeSwap(): number;
export interface NetworkInfo {
name: string;
address: string;
netmask?: string;
family: 'IPv4' | 'IPv6';
}
export function networkInterfaces(): Array<NetworkInfo>;
32 changes: 15 additions & 17 deletions lib/utils/spawn.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
declare module 'bun-utilities/spawn' {
export interface ProcessResult {
stdout?: string;
stderr?: string;
exitCode?: number;
isExecuted: boolean;
}
export interface Options {
cwd?: string;
stdin?: 'inherit' | 'piped' | null;
stdout?: 'inherit' | 'piped' | null;
stderr?: 'inherit' | 'piped' | null;
}
export function exec(commandWithArgs: Array<string>, options?: Options | undefined | null): { stdout: undefined, stderr: undefined, exitCode?: number, isExecuted: false } | { stdout: string, stderr: string, exitCode?: number, isExecuted: true };
export function spawn(command: string, args: Array<string>, options?: Options | undefined | null): { stdout: undefined, stderr: undefined, exitCode?: number, isExecuted: false } | { stdout: string, stderr: string, exitCode?: number, isExecuted: true };
export function execAndDontWait(commandWithArgs: Array<string>, options?: Options | undefined | null): ProcessResult;
export function spawnAndDontWait(command: string, args: Array<string>, options?: Options | undefined | null): { isExecuted: true };
export interface ProcessResult {
stdout?: string;
stderr?: string;
exitCode?: number;
isExecuted: boolean;
}
export interface Options {
cwd?: string;
stdin?: 'inherit' | 'piped' | null;
stdout?: 'inherit' | 'piped' | null;
stderr?: 'inherit' | 'piped' | null;
}
export function exec(commandWithArgs: Array<string>, options?: Options | undefined | null): { stdout: undefined, stderr: undefined, exitCode?: number, isExecuted: false } | { stdout: string, stderr: string, exitCode?: number, isExecuted: true };
export function spawn(command: string, args: Array<string>, options?: Options | undefined | null): { stdout: undefined, stderr: undefined, exitCode?: number, isExecuted: false } | { stdout: string, stderr: string, exitCode?: number, isExecuted: true };
export function execAndDontWait(commandWithArgs: Array<string>, options?: Options | undefined | null): ProcessResult;
export function spawnAndDontWait(command: string, args: Array<string>, options?: Options | undefined | null): { isExecuted: true };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bun-utilities",
"version": "0.2.0",
"version": "0.2.1",
"description": "Bindings for useful functions for bun ",
"napi": {
"name": "bun-utilities",
Expand Down
16 changes: 11 additions & 5 deletions scripts/bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const header = [
'',
''
].join('\n');
const filesToCat = (await getXFiles('.d.ts')).filter(f => !['index.d.ts'].some(tf => f.includes(tf)));
const fileContents = [];
const filesToCat = await getXFiles('.d.ts');
/*const fileContents = [];
for (let i = 0; i < filesToCat.length; i++) {
const name = filesToCat[i];
Expand All @@ -35,7 +35,13 @@ for (let i = 0; i < filesToCat.length; i++) {
}
const text = header + fileContents.join('\n');
await writeFile(join(folder, 'types.d.ts'), text);
await writeFile(join(folder, 'types.d.ts'), text);*/
for (const file of filesToCat) {
let content = (await readFile(resolve(__dirname, '..', file))).toString();
if (file.includes('index.d.ts')) content = content.replaceAll('./utils/', './');

writeFile(join(folder, basename(file)), content);
}

const dotJsFiles = await getXFiles('.js');
const dotMJsFiles = await getXFiles('.mjs');
Expand Down Expand Up @@ -66,8 +72,8 @@ const packageJson = {
types: './types.d.ts',
exports: {
'.': {
import: './spawn.mjs',
require: './spawn.js'
import: './index.mjs',
require: './index.js'
},
'./fs': {
import: './fs.mjs',
Expand Down

0 comments on commit a957a03

Please sign in to comment.