Skip to content

Commit

Permalink
Merge pull request #70 from long-woo/fix/plugin_js
Browse files Browse the repository at this point in the history
fix(plugin): 修复 js 插件卡住问题
  • Loading branch information
long-woo authored Aug 26, 2024
2 parents ff6a4f9 + 7dee6f3 commit d24b00e
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: ['master']
paths:
- src/npm/package.json
- src/npm/pkg.json

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ For convenience, STC can not only develop plugins in Deno, but also provides `@l

```ts
// 引用模块
import { start } from 'https://deno.land/x/stc@1.6.1/mod.ts'
import { start } from 'https://deno.land/x/stc@1.6.4/mod.ts'

// 定义插件
const myPlugin: IPlugin = {
Expand Down
7 changes: 4 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@loongwoo/stc",
"version": "1.6.3",
"version": "1.6.4",
"exports": "./mod.ts",
"tasks": {
"dev": "deno run -A --watch=src src/main.ts --url 'https://petstore3.swagger.io/api/v3/openapi.json'",
"serve": "deno run -A --watch=src src/service.ts",
"version": "echo '1.6.3' > release/version",
"version": "echo '1.6.4' > release/version",
"build:npm": "deno run -A src/npm/index.ts",
"build:mac": "deno compile -A --target x86_64-apple-darwin --output release/stc src/main.ts",
"build:mac-m": "deno compile -A --target aarch64-apple-darwin --output release/stc-m src/main.ts",
Expand Down Expand Up @@ -38,7 +38,8 @@
},
"test": {
"include": [
"test/"
"test/",
"src/plugins/*/test/*"
],
"exclude": [
"out",
Expand Down
26 changes: 25 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/npm/pkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@loongwoo/stc",
"version": "1.6.3",
"version": "1.6.4",
"description": "OpenApi/Swagger/Apifox document conversion tool.\nOpenAPI(Swagger)、Apifox 文档转换为接口文件。",
"type": "module",
"module": "esm/mod.js",
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/javascript/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as esbuild from "x/esbuild@v0.20.1/mod.js";
import * as esbuild from "x/esbuild@v0.23.1/mod.js";

import type { ISwaggerOptions } from "../../swagger.ts";
import type {
Expand Down Expand Up @@ -116,5 +116,7 @@ export const JavaScriptPlugin: IPlugin = {
`${pluginOptions.outDir}/shared/fetchRuntime.js`,
_fetchRuntimeFileContent,
);

esbuild.stop();
},
};
17 changes: 17 additions & 0 deletions src/plugins/javascript/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { assertEquals } from "std/assert/mod.ts";

Deno.test("JavaScript 插件", async () => {
const command = new Deno.Command("deno", {
args: [
"run",
"-A",
"src/main.ts",
"--url=https://petstore3.swagger.io/api/v3/openapi.json",
"--lang=js",
],
});

const { code } = await command.output();

assertEquals(0, code);
});

0 comments on commit d24b00e

Please sign in to comment.