Skip to content

Commit fac8104

Browse files
authored
chore!: Move to Pure ESM (#17)
* update * fix * add submodule * up
1 parent 69a1379 commit fac8104

File tree

10 files changed

+476
-513
lines changed

10 files changed

+476
-513
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: test
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
name: "Test on Node.js ${{ matrix.node-version }}"
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
node-version: [ 16, 18 ]
10+
steps:
11+
- name: checkout
12+
uses: actions/checkout@v3
13+
with:
14+
submodules: recursive
15+
- name: setup Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- name: Install
20+
run: yarn install
21+
- name: Test
22+
run: yarn test

.travis.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# technological-book-corpus-ja [![Build Status](https://travis-ci.org/textlint-ja/technological-book-corpus-ja.svg?branch=master)](https://travis-ci.org/textlint-ja/technological-book-corpus-ja)
1+
# technological-book-corpus-ja [![Actions Status: test](https://github.com/textlint-ja/technological-book-corpus-ja/workflows/test/badge.svg)](https://github.com/textlint-ja/technological-book-corpus-ja/actions?query=workflow%3A"test")
22

33
日本語技術書のコーパス。
44

bin/technological-book-corpus-ja.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env node
2-
const get = require('../').get;
3-
const findByPattern = require('../').findByPattern;
2+
import { findByPattern, get } from "../index.js";
43
if (process.argv[2]) {
54
console.log(findByPattern(process.argv[2]).join("\n"));
65
} else {
76
console.log(get().join("\n"));
8-
}
7+
}

build.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
// MIT © 2017 azu
22
"use strict";
3-
const cpx = require("cpx");
4-
const path = require("path");
3+
import cpx from "cpx";
4+
import url from "node:url";
5+
import path from "node:path";
6+
import fs from "fs";
7+
import addTextToMarkdown from "add-text-to-markdown";
8+
import { References as Refs } from "./index.js";
9+
10+
const __filename__ = url.fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename__);
512
const repoDir = path.join(__dirname, "repo");
613
const sourceDir = path.join(__dirname, "source");
7-
const fs = require("fs");
8-
const addTextToMarkdown = require("add-text-to-markdown");
9-
const Refs = require("./index").References;
1014

1115
/**
1216
*

index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// MIT © 2017 azu
22
"use strict";
3-
const globby = require('globby');
4-
const path = require("path");
3+
import { globbySync} from "globby";
4+
import url from "node:url";
5+
import path from "node:path";
6+
const __filename__ = url.fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename__);
8+
59
const References = {
610
"js-primer": {
711
name: "js-primer",
@@ -54,7 +58,7 @@ const sourceDir = path.join(__dirname, "source");
5458
* @see https://github.com/isaacs/node-glob
5559
*/
5660
function findByPattern(patterns) {
57-
return globby.sync(path.join(sourceDir, patterns), {
61+
return globbySync(path.join(sourceDir, patterns), {
5862
nodir: true
5963
});
6064
}
@@ -69,6 +73,8 @@ function get(ext = ".*") {
6973
return findByPattern(`/**/*${ext}`);
7074
}
7175

72-
module.exports.References = References;
73-
module.exports.findByPattern = findByPattern;
74-
module.exports.get = get;
76+
export {
77+
References,
78+
findByPattern,
79+
get
80+
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"version": "2.0.1",
1414
"description": "日本語で書かれた技術書のコーパス",
1515
"main": "lib/index.js",
16+
"type": "module",
1617
"bin": {
1718
"technological-book-corpus-ja": "./bin/technological-book-corpus-ja.js"
1819
},
@@ -38,11 +39,11 @@
3839
},
3940
"homepage": "https://github.com/textlint-ja/technological-book-corpus-ja",
4041
"dependencies": {
41-
"globby": "^10.0.1"
42+
"globby": "^13.1.2"
4243
},
4344
"devDependencies": {
4445
"add-text-to-markdown": "^2.0.0",
4546
"cpx": "^1.5.0",
46-
"mocha": "^6.2.2"
47+
"mocha": "^10.1.0"
4748
}
4849
}

test/index-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// MIT © 2017 azu
22
"use strict";
3-
const assert = require("assert");
4-
const path = require("path");
5-
const corpus = require("../index");
3+
import assert from "assert";
4+
import path from "path";
5+
import * as corpus from "../index.js";
6+
67
describe("technological-book-corpus-ja", () => {
78
describe("#get", () => {
89
it("should get all files", () => {

0 commit comments

Comments
 (0)