Skip to content

Commit

Permalink
refactor(misskey-js): lint build.js
Browse files Browse the repository at this point in the history
  • Loading branch information
zyoshoka committed Jun 28, 2024
1 parent 0ec1ea6 commit 44d89bd
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions packages/misskey-js/build.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import * as esbuild from "esbuild";
import { build } from "esbuild";
import { globSync } from "glob";
import { execa } from "execa";
import fs from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname } from "node:path";
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import * as esbuild from 'esbuild';
import { build } from 'esbuild';
import { globSync } from 'glob';
import { execa } from 'execa';

const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
const _package = JSON.parse(fs.readFileSync(_dirname + '/package.json', 'utf-8'));

const entryPoints = globSync("./src/**/**.{ts,tsx}");
const entryPoints = globSync('./src/**/**.{ts,tsx}');

/** @type {import('esbuild').BuildOptions} */
const options = {
entryPoints,
minify: process.env.NODE_ENV === 'production',
outdir: "./built",
target: "es2022",
platform: "browser",
format: "esm",
outdir: './built',
target: 'es2022',
platform: 'browser',
format: 'esm',
sourcemap: 'linked',
};

// built配下をすべて削除する
fs.rmSync('./built', { recursive: true, force: true });

if (process.argv.map(arg => arg.toLowerCase()).includes("--watch")) {
if (process.argv.map(arg => arg.toLowerCase()).includes('--watch')) {
await watchSrc();
} else {
await buildSrc();
Expand All @@ -36,7 +36,7 @@ async function buildSrc() {
console.log(`[${_package.name}] start building...`);

await build(options)
.then(it => {
.then(() => {
console.log(`[${_package.name}] build succeeded.`);
})
.catch((err) => {
Expand Down Expand Up @@ -65,7 +65,7 @@ function buildDts() {
{
stdout: process.stdout,
stderr: process.stderr,
}
},
);
}

Expand All @@ -86,7 +86,7 @@ async function watchSrc() {
},
}];

console.log(`[${_package.name}] start watching...`)
console.log(`[${_package.name}] start watching...`);

const context = await esbuild.context({ ...options, plugins });
await context.watch();
Expand Down

0 comments on commit 44d89bd

Please sign in to comment.