From b6377ec5b55b1f6bb75093e2afb3432831db4b19 Mon Sep 17 00:00:00 2001 From: jigsaw Date: Fri, 30 Jan 2015 13:52:47 +0900 Subject: [PATCH 1/2] fix any extension replace to js --- src/index.coffee | 4 +++- test/index.coffee | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/index.coffee b/src/index.coffee index 3c4e3cf..68d1dce 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -8,7 +8,9 @@ module.exports = (opts)-> if file.isStream() then return callback new gutil.PluginError('gulp-article', 'Stream not supported') file.contents = new Buffer compile file.contents.toString(), opts - file.path = file.path.replace /\.tag/, '.js' + splitedPath = file.path.split('.') + splitedPath[splitedPath.length - 1] = 'js' + file.path = splitedPath.join('.') callback null, file through.obj transform diff --git a/test/index.coffee b/test/index.coffee index 00a0c44..5c86419 100644 --- a/test/index.coffee +++ b/test/index.coffee @@ -56,3 +56,23 @@ it 'should use compile options', (callback)-> path: '/hoge/fuga.tag' stream.end() + +it 'should jade extension rename js', (callback)-> + stream = riot() + + stream.once 'data', (file)-> + contents = file.contents.toString() + assert.equal file.path, '/hoge/fuga.js' + callback() + + stream.write new gutil.File + contents: new Buffer ''' + +

test { sample }

+ + this.sample = 'hoge' +
+ ''' + path: '/hoge/fuga.jade' + + stream.end() From 9b0e630fbb4c373af8e6ac94d90658909e0d4fb3 Mon Sep 17 00:00:00 2001 From: jigsaw Date: Fri, 30 Jan 2015 13:53:34 +0900 Subject: [PATCH 2/2] add build js --- build/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/index.js b/build/index.js index 4e09beb..6dfc048 100644 --- a/build/index.js +++ b/build/index.js @@ -10,6 +10,7 @@ module.exports = function(opts) { var transform; transform = function(file, encoding, callback) { + var splitedPath; if (file.isNull()) { return callback(null, file); } @@ -17,7 +18,9 @@ return callback(new gutil.PluginError('gulp-article', 'Stream not supported')); } file.contents = new Buffer(compile(file.contents.toString(), opts)); - file.path = file.path.replace(/\.tag/, '.js'); + splitedPath = file.path.split('.'); + splitedPath[splitedPath.length - 1] = 'js'; + file.path = splitedPath.join('.'); return callback(null, file); }; return through.obj(transform);