diff --git a/packages/react-server-gulp-module-tagger/index.js b/packages/react-server-gulp-module-tagger/index.js index 647d4f47c..26afe0711 100644 --- a/packages/react-server-gulp-module-tagger/index.js +++ b/packages/react-server-gulp-module-tagger/index.js @@ -6,13 +6,19 @@ var replace = require("gulp-replace") // - "__LOGGER__" // - "__LOGGER__({ /* options */ })" var isWindows = ('win32' === process.platform) -, REPLACE_TOKEN = /(?:__LOGGER__|__CHANNEL__|__CACHE__)(?:\(\s*(\{[\s\S]*?\})\s*\))?/g +, DEFAULT_REPLACE_TOKEN = /(?:__LOGGER__|__CHANNEL__|__CACHE__)(?:\(\s*(\{[\s\S]*?\})\s*\))?/g , THIS_MODULE = isWindows ? /(?:[^\\]+\\node_modules\\)?react-server-gulp-module-tagger\\index\.js$/ : /(?:[^\/]+\/node_modules\/)?react-server-gulp-module-tagger\/index\.js$/ module.exports = function(config) { config || (config = {}); + var REPLACE_TOKEN; + if (config.token) { + REPLACE_TOKEN = new RegExp("(?:" + config.token + ")(?:\\(\\s*(\\{[\\s\\S]*?\\})\\s*\\))?", 'g'); + } else { + REPLACE_TOKEN = DEFAULT_REPLACE_TOKEN; + } config.basePath = module.filename.replace(THIS_MODULE,''); return forEach(function(stream, file){ return stream.pipe(replace(REPLACE_TOKEN, (match, optString) => { diff --git a/packages/react-server-gulp-module-tagger/test/fixtures/custom-token/expected.js b/packages/react-server-gulp-module-tagger/test/fixtures/custom-token/expected.js index b3afe9e3e..12853bd4f 100644 --- a/packages/react-server-gulp-module-tagger/test/fixtures/custom-token/expected.js +++ b/packages/react-server-gulp-module-tagger/test/fixtures/custom-token/expected.js @@ -1,3 +1,3 @@ var logger = require('react-server').logging.getLogger({"name":"react-server-gulp-module-tagger.test.fixtures.custom-token.actual","color":{"server":219,"client":"rgb(212,127,212)"}}); -var fooLogger = logging.getLogger({"label":"foo","name":"react-server-gulp-module-tagger.test.fixtures.custom-token.actual.foo","color":{"server":219,"client":"rgb(212,127,212)"}}); -var barLogger = logging.getLogger({"label":"bar","name":"react-server-gulp-module-tagger.test.fixtures.custom-token.actual.bar","color":{"server":219,"client":"rgb(212,127,212)"}}); +var fooLogger = logging.getLogger({"label":"foo","name":"react-server-gulp-module-tagger.test.fixtures.custom-token.actual.foo","color":{"server":83,"client":"rgb(42,212,42)"}}); +var barLogger = logging.getLogger({"label":"bar","name":"react-server-gulp-module-tagger.test.fixtures.custom-token.actual.bar","color":{"server":71,"client":"rgb(42,127,42)"}});