Skip to content
This repository has been archived by the owner on May 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #32 from textlint/update-deps
Browse files Browse the repository at this point in the history
chore(deps): update dependencies
  • Loading branch information
azu authored Jul 6, 2019
2 parents 1b5e25c + 134f6da commit a498b92
Show file tree
Hide file tree
Showing 15 changed files with 1,266 additions and 282 deletions.
8 changes: 4 additions & 4 deletions bin/cmd.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node
var spawn = require("cross-spawn");
var script = process.argv[2];
var args = process.argv.slice(3);
const spawn = require("cross-spawn");
const script = process.argv[2];
const args = process.argv.slice(3);

switch (script) {
case "init":
case "build":
case "test":
var result = spawn.sync("node", [require.resolve("../scripts/" + script)].concat(args), { stdio: "inherit" });
const result = spawn.sync("node", [require.resolve("../scripts/" + script)].concat(args), { stdio: "inherit" });
process.exit(result.status);
break;
default:
Expand Down
3 changes: 1 addition & 2 deletions configs/babel-register.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"use strict";
require("@babel/register")(require("./babelrc"));
require("@babel/register")(require("./babel.config"));
18 changes: 18 additions & 0 deletions configs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
presets: [
[
"@babel/env",
{
// For async/await support
// https://babeljs.io/docs/en/babel-preset-env#targetsesmodules
targets: {
esmodules: true
}
}
]
],
plugins: [
// inline fs content
"static-fs"
]
};
3 changes: 0 additions & 3 deletions configs/babelrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"build": "textlint-scripts build",
"test": "textlint-scripts test"
},
"dependencies": {
"prh": "^5.4.3"
},
"devDependencies": {
"textlint-scripts": "file:../"
}
Expand Down
8 changes: 8 additions & 0 deletions example/src/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const prh = require("prh");
const fs = require("fs");
const path = require("path");
module.exports = function(text) {
const dict = fs.readFileSync(path.join(__dirname, "prh.yml"), "utf-8");
const engine = prh.fromYAML("", dict);
return engine.makeChangeSet("", text);
};
20 changes: 19 additions & 1 deletion example/src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
"use strict";
import assert from "assert";
import mod from "./module";

const path = require("path");
const common = require("./common");
module.exports = function(context, options = {}) {
const { Syntax, RuleError, report, getSource } = context;
return {
// async test
async [Syntax.Code](node) {
return null;
},
[Syntax.Str](node) {
// "Str" node
const text = getSource(text);
// check prh
const result = common(text);
if (result.diffs.length > 0) {
result.diffs.forEach(diff => {
const ruleError = new RuleError("Found " + diff.expected + "!", {
index: diff.index // padding of index
});
report(node, ruleError);
});
}
// check inline
if (/bugs/.test(text)) {
const indexOfBugs = text.search(/bugs/);
const ruleError = new RuleError("Found bugs.", {
Expand Down
1 change: 1 addition & 0 deletions example/src/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
8 changes: 8 additions & 0 deletions example/src/prh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 1
rules:
- expected: jQuery
specs:
- from: jquery
to: jQuery
- from: JQUERY
to: jQuery
10 changes: 10 additions & 0 deletions example/test/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ tester.run("rule", rule, {
"OK."
],
invalid: [
// inline file
{
text: "jquery",
errors: [
{
message: "Found jQuery!",
index: 0
}
]
},
// single match
{
text: "It is bugs.",
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@
},
"homepage": "https://github.com/textlint/textlint-scripts",
"devDependencies": {
"husky": "^2.7.0",
"lint-staged": "^8.2.1",
"husky": "^3.0.0",
"lint-staged": "^9.0.2",
"prettier": "^1.8.1"
},
"dependencies": {
"@babel/cli": "^7.5.0",
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.0",
"@babel/register": "^7.4.4",
"babel-plugin-static-fs": "^1.2.0",
"confirmer": "^1.1.2",
"cross-spawn": "^6.0.5",
"mocha": "^5.2.0",
"mocha": "^6.1.4",
"pkg-to-readme": "^1.1.0",
"textlint-tester": "^5.1.7"
},
Expand Down
12 changes: 6 additions & 6 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// Do this as the first thing so that any code reading it knows the right env.
process.env.NODE_ENV = "production";

var spawn = require("cross-spawn");
var args = process.argv.slice(2);
var babel = require.resolve(".bin/babel");
var babelrc = require("../configs/babelrc");
const spawn = require("cross-spawn");
const args = process.argv.slice(2);
const babel = require.resolve(".bin/babel");
const babelConfigFilePath = require.resolve("../configs/babel.config");
// babel src --out-dir lib --watch --source-maps
var child = spawn(
const child = spawn(
babel,
["--presets", babelrc.presets.join(","), "--source-maps", "--out-dir", "lib", "src"].concat(args)
["--config-file", babelConfigFilePath, "--source-maps", "--out-dir", "lib", "src"].concat(args)
);
child.stderr.on("data", function(data) {
process.stderr.write(data);
Expand Down
10 changes: 5 additions & 5 deletions scripts/init.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// LICENSE : MIT
"use strict";
var path = require("path");
var confirmer = require("confirmer");
var pkgToReadme = require("pkg-to-readme");
var fs = require("fs");
const fs = require("fs");
const path = require("path");
const confirmer = require("confirmer");
const pkgToReadme = require("pkg-to-readme");
// Update README.md
var templatePath = path.resolve(__dirname, "..", "configs", "README.md.template");
const templatePath = path.resolve(__dirname, "..", "configs", "README.md.template");
Promise.resolve()
.then(function() {
if (!fs.existsSync(path.resolve("README.md"))) {
Expand Down
10 changes: 5 additions & 5 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// LICENSE : MIT
"use strict";
process.env.NODE_ENV = "test";
var spawn = require("cross-spawn");
var args = process.argv.slice(2);
var mocha = require.resolve(".bin/mocha");
const spawn = require("cross-spawn");
const args = process.argv.slice(2);
const mocha = require.resolve(".bin/mocha");
// mocha
var babelRegisterPath = require.resolve("../configs/babel-register");
var child = spawn(mocha, ["--require", babelRegisterPath, "--timeout", "5000", "--recursive", "test/"].concat(args));
const babelRegisterPath = require.resolve("../configs/babel-register");
const child = spawn(mocha, ["--require", babelRegisterPath, "--timeout", "10000", "--recursive", "test/"].concat(args));

child.stderr.on("data", function(data) {
process.stderr.write(data);
Expand Down
Loading

0 comments on commit a498b92

Please sign in to comment.