Skip to content

Commit 4df19e2

Browse files
committed
refactor: through2 を使わず node の stream を使うようにした
1 parent 132f2c7 commit 4df19e2

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

_tools/gulp/format-code.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
var through2 = require('through2');
2-
var reg = /require\(["']power-assert["']\)/g;
1+
const { Transform } = require("stream");
2+
const reg = /require\(["']power-assert["']\)/g;
33

44
function modifier(str) {
55
// power-assert -> assert
66
// strict use strict
7-
return str.replace(reg, 'require("assert")').replace(/["']use strict["'];?\n/g, "")
7+
return str.replace(reg, "require(\"assert\")").replace(/["']use strict["'];?\n/g, "");
88
}
99

1010
function modify() {
11-
return through2.obj(function (file, encoding, done) {
12-
var content = modifier(String(file.contents));
13-
file.contents = new Buffer(content);
14-
this.push(file);
15-
done();
11+
return new Transform({
12+
objectMode: true,
13+
transform(file, encoding, callback) {
14+
const content = modifier(String(file.contents));
15+
file.contents = Buffer.from(content);
16+
this.push(file);
17+
callback();
18+
}
1619
});
1720
}
1821

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"textlint-plugin-asciidoctor": "^1.0.3",
6969
"textlint-rule-eslint": "4.0.1",
7070
"textlint-rule-prh": "^5.2.1",
71-
"through2": "^3.0.1",
7271
"vinyl-source-stream": "^2.0.0"
7372
}
7473
}

0 commit comments

Comments
 (0)