-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #386 [Enhancement][WIP] Add @thin-hook/demo-convert-skinny and …
…@thin-hook/demo-convert-full plugins
- Loading branch information
Showing
7 changed files
with
146 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
@license https://github.com/t2ym/thin-hook/blob/master/LICENSE.md | ||
Copyright (c) 2020, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved. | ||
*/ | ||
const path = require('path'); | ||
const through = require('through2'); | ||
|
||
const pluginName = '@thin-hook/demo-convert-full'; | ||
|
||
const configurator = function (targetConfig) { | ||
const destPath = path.resolve(this.path.base, this.path.root); | ||
|
||
return () => this.gulp.src([ path.resolve(destPath, '**/*') ], { base: destPath }) | ||
.pipe(through.obj((file, enc, callback) => { | ||
if (file.path.match(/\.html$/)) { | ||
let html = String(file.contents); | ||
html = html.replace(/<!--{{{/g, '<!--__BEGIN__-->').replace(/}}}-->/g, '<!--__END__-->').replace(/\/\*{{{/g, '/*__BEGIN__*/').replace(/}}}\*\//g, '/*__END__*/'); | ||
file.contents = Buffer.from(html); | ||
callback(null, file); | ||
} | ||
else if (file.path.match(/\.js$/)) { | ||
let js = String(file.contents); | ||
js = js.replace(/\/\*{{{/g, '/*__BEGIN__*/').replace(/}}}\*\//g, '/*__END__*/'); | ||
file.contents = Buffer.from(js); | ||
callback(null, file); | ||
} | ||
else { | ||
callback(null, null); | ||
} | ||
})) | ||
.pipe(this.gulp.dest(destPath)) | ||
} | ||
|
||
module.exports = { | ||
configurator, | ||
name: pluginName, | ||
dependencies: [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@thin-hook/demo-convert-full", | ||
"version": "0.0.0", | ||
"description": "thin-hook plugin for demo convertion to full mode", | ||
"main": "configurator.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/t2ym/thin-hook.git" | ||
}, | ||
"keywords": [ | ||
"thin-hook", | ||
"plugin" | ||
], | ||
"author": "Tetsuya Mori <t2y3141592@gmail.com>", | ||
"license": "BSD-2-Clause", | ||
"bugs": { | ||
"url": "https://github.com/t2ym/thin-hook/issues" | ||
}, | ||
"homepage": "https://github.com/t2ym/thin-hook#readme", | ||
"dependencies": { | ||
"through2": "^2.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
@license https://github.com/t2ym/thin-hook/blob/master/LICENSE.md | ||
Copyright (c) 2020, Tetsuya Mori <t2y3141592@gmail.com>. All rights reserved. | ||
*/ | ||
const path = require('path'); | ||
const through = require('through2'); | ||
|
||
const pluginName = '@thin-hook/demo-convert-skinny'; | ||
|
||
const configurator = function (targetConfig) { | ||
const destPath = path.resolve(this.path.base, this.path.root); | ||
|
||
return () => this.gulp.src([ path.resolve(destPath, '**/*') ], { base: destPath }) | ||
.pipe(through.obj((file, enc, callback) => { | ||
if (file.path.match(/\.html$/)) { | ||
let html = String(file.contents); | ||
html = html.replace(/<!--__BEGIN__-->/g, '<!--{{{').replace(/<!--__END__-->/g, '}}}-->').replace(/\/\*__BEGIN__\*\//g, '/*{{{').replace(/\/\*__END__\*\//g, '}}}*/'); | ||
file.contents = Buffer.from(html); | ||
callback(null, file); | ||
} | ||
else if (file.path.match(/\.js$/)) { | ||
let js = String(file.contents); | ||
js = js.replace(/\/\*__BEGIN__\*\//g, '/*{{{').replace(/\/\*__END__\*\//g, '}}}*/'); | ||
file.contents = Buffer.from(js); | ||
callback(null, file); | ||
} | ||
else { | ||
callback(null, null); | ||
} | ||
})) | ||
.pipe(this.gulp.dest(destPath)) | ||
} | ||
|
||
module.exports = { | ||
configurator, | ||
name: pluginName, | ||
dependencies: [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@thin-hook/demo-convert-skinny", | ||
"version": "0.0.0", | ||
"description": "thin-hook plugin for demo convertion to skinny mode", | ||
"main": "configurator.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/t2ym/thin-hook.git" | ||
}, | ||
"keywords": [ | ||
"thin-hook", | ||
"plugin" | ||
], | ||
"author": "Tetsuya Mori <t2y3141592@gmail.com>", | ||
"license": "BSD-2-Clause", | ||
"bugs": { | ||
"url": "https://github.com/t2ym/thin-hook/issues" | ||
}, | ||
"homepage": "https://github.com/t2ym/thin-hook#readme", | ||
"dependencies": { | ||
"through2": "^2.0.3" | ||
} | ||
} |