@wasm-fmt/gofmt 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +5 -4
- package/.editorconfig +0 -11
- package/.gitattributes +0 -5
- package/.node-version +0 -1
- package/gen_patch.sh +0 -23
- package/src/lib.go +0 -23
- package/test.js +0 -29
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://github.com/wasm-fmt/gofmt/actions/workflows/test.yml)
|
|
2
2
|
[](https://www.npmjs.com/package/@wasm-fmt/gofmt)
|
|
3
3
|
|
|
4
4
|
# Install
|
|
@@ -40,8 +40,8 @@ git clone https://github.com/wasm-fmt/gofmt.git
|
|
|
40
40
|
# 2. install TinyGo https://tinygo.org/getting-started/install/
|
|
41
41
|
|
|
42
42
|
# 3. build
|
|
43
|
-
|
|
43
|
+
pnpm build
|
|
44
44
|
|
|
45
45
|
# 4. test
|
|
46
|
-
|
|
46
|
+
pnpm run /^test:/
|
|
47
47
|
```
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@wasm-fmt/gofmt",
|
|
3
3
|
"description": "A wasm based golang formatter",
|
|
4
4
|
"author": "magic-akari <akari.ccino@gamil.com>",
|
|
5
|
-
"version": "0.4.
|
|
5
|
+
"version": "0.4.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"wasm",
|
|
@@ -38,13 +38,14 @@
|
|
|
38
38
|
"patch": "git apply ./gofmt.patch",
|
|
39
39
|
"build": "tinygo build -o=gofmt.wasm -target=wasm -no-debug -stack-size=24kb ./src/lib.go",
|
|
40
40
|
"postbuild": "npm run gofmt && npm run patch",
|
|
41
|
-
"test": "node --test"
|
|
41
|
+
"test:node": "node --test test_node",
|
|
42
|
+
"test:deno": "deno test test_deno --allow-read",
|
|
43
|
+
"test:bun": "bun test test_bun"
|
|
42
44
|
},
|
|
43
45
|
"engines": {
|
|
44
46
|
"node": ">=16.17.0"
|
|
45
47
|
},
|
|
46
48
|
"publishConfig": {
|
|
47
|
-
"access": "public"
|
|
48
|
-
"provenance": true
|
|
49
|
+
"access": "public"
|
|
49
50
|
}
|
|
50
51
|
}
|
package/.editorconfig
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Check http://editorconfig.org for more information
|
|
2
|
-
# This is the main config file for this project:
|
|
3
|
-
root = true
|
|
4
|
-
|
|
5
|
-
[*]
|
|
6
|
-
charset = utf-8
|
|
7
|
-
trim_trailing_whitespace = true
|
|
8
|
-
end_of_line = lf
|
|
9
|
-
indent_style = tab
|
|
10
|
-
insert_final_newline = true
|
|
11
|
-
indent_size = 4
|
package/.gitattributes
DELETED
package/.node-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v18.17.0
|
package/gen_patch.sh
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
current_dir=$(pwd)
|
|
2
|
-
tmp_dir=$(mktemp -d)
|
|
3
|
-
|
|
4
|
-
cd $tmp_dir
|
|
5
|
-
git init
|
|
6
|
-
|
|
7
|
-
cp $(tinygo env TINYGOROOT)/targets/wasm_exec.js $tmp_dir/gofmt.js
|
|
8
|
-
git add -f .
|
|
9
|
-
git commit -m "init"
|
|
10
|
-
|
|
11
|
-
cp $current_dir/gofmt.js $tmp_dir/gofmt.js
|
|
12
|
-
git add -f .
|
|
13
|
-
|
|
14
|
-
git diff \
|
|
15
|
-
--cached \
|
|
16
|
-
--no-color \
|
|
17
|
-
--ignore-space-at-eol \
|
|
18
|
-
--no-ext-diff \
|
|
19
|
-
--src-prefix=a/ \
|
|
20
|
-
--dst-prefix=b/ \
|
|
21
|
-
>$current_dir/gofmt.patch
|
|
22
|
-
|
|
23
|
-
rm -rf $tmp_dir
|
package/src/lib.go
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
package main
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"go/format"
|
|
5
|
-
"syscall/js"
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
func Format(this js.Value, args []js.Value) any {
|
|
9
|
-
input := ([]byte)(args[0].String())
|
|
10
|
-
|
|
11
|
-
output, err := format.Source(input)
|
|
12
|
-
if err != nil {
|
|
13
|
-
return []any{true, err.Error()}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return []any{false, string(output)}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
func main() {
|
|
20
|
-
done := make(chan bool)
|
|
21
|
-
js.Global().Set("format", js.FuncOf(Format))
|
|
22
|
-
<-done
|
|
23
|
-
}
|
package/test.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import test from "node:test";
|
|
4
|
-
import init, { format } from "./gofmt.js";
|
|
5
|
-
|
|
6
|
-
await init();
|
|
7
|
-
|
|
8
|
-
const files = (await fs.readdir("testdata"))
|
|
9
|
-
.filter((f) => f.endsWith(".input"))
|
|
10
|
-
.map((f) => {
|
|
11
|
-
return {
|
|
12
|
-
input_name: f,
|
|
13
|
-
golden_name: f.replace(".input", ".golden"),
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
for (const { input_name, golden_name } of files) {
|
|
18
|
-
test(`format ${input_name}`, { skip: input_name[0] === "." }, async () => {
|
|
19
|
-
const [input, expected] = await Promise.all(
|
|
20
|
-
[input_name, golden_name].map((f) =>
|
|
21
|
-
fs.readFile(`testdata/${f}`, "utf-8")
|
|
22
|
-
)
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const actual = format(input);
|
|
26
|
-
|
|
27
|
-
assert.equal(actual, expected);
|
|
28
|
-
});
|
|
29
|
-
}
|