diff --git a/hopp.lock b/hopp.lock index 50cdf65..4fa18cb 100644 --- a/hopp.lock +++ b/hopp.lock @@ -1 +1 @@ -{"v":"1.2.6","p":{"hopp-plugin-eslint":{},"hopp-plugin-babel":{}},"pl":[1499318242000,{"hopp-plugin-babel":["config","default"],"hopp-plugin-eslint":["config","format","failOnError","default"]}],"lp":{"hopp-plugin-babel":"/Users/karimsa/projects/hoppjs/hopp/packages/hopp-plugin-babel","hopp-plugin-eslint":"/Users/karimsa/projects/hoppjs/hopp/packages/hopp-plugin-eslint"},"_":[0,null],"sc":{"lint-accord":{"./packages/hopp-plugin-accord/lib/index.js":1499464156000},"lint-babel":{"./packages/hopp-plugin-babel/lib/index.js":1499464156000},"lint-concat":{"./packages/hopp-plugin-concat/lib/index.js":1499464156000},"lint-notify":{"./packages/hopp-plugin-notify/lib/index.js":1499464156000},"lint-eslint":{"./packages/hopp-plugin-eslint/lib/index.js":1499464156000},"hopp-latest":{"./packages/hopp/src/cache.js":1499221452000,"./packages/hopp/src/compat/else.js":1499447625000,"./packages/hopp/src/fs/get-path.js":1499150171000,"./packages/hopp/src/fs/glob.js":1499318099000,"./packages/hopp/src/fs/index.js":1499221452000,"./packages/hopp/src/hopp.js":1499318099000,"./packages/hopp/src/hoppfile/find.js":1499221452000,"./packages/hopp/src/hoppfile/index.js":1499150171000,"./packages/hopp/src/hoppfile/load.js":1499221452000,"./packages/hopp/src/index.js":1499293987000,"./packages/hopp/src/streams/buffer.js":1499150171000,"./packages/hopp/src/streams/bundle.js":1499221452000,"./packages/hopp/src/streams/index.js":1499150171000,"./packages/hopp/src/streams/map.js":1499150171000,"./packages/hopp/src/streams/readstream.js":1499294007000,"./packages/hopp/src/tasks/goal.js":1499318099000,"./packages/hopp/src/tasks/loadPlugins.js":1499293987000,"./packages/hopp/src/tasks/mgr.js":1499463285000,"./packages/hopp/src/tasks/parallel.js":1499318099000,"./packages/hopp/src/tasks/steps.js":1499318099000,"./packages/hopp/src/tasks/tree.js":1499150171000,"./packages/hopp/src/tasks/watch.js":1499150171000,"./packages/hopp/src/utils/_.js":1499150171000,"./packages/hopp/src/utils/deep-equal.js":1499150171000,"./packages/hopp/src/utils/error.js":1499318099000,"./packages/hopp/src/utils/fn.js":1499221452000,"./packages/hopp/src/utils/index.js":1499318099000,"./packages/hopp/src/utils/log.js":1499221452000},"build-accord":{"./packages/hopp-plugin-accord/lib/index.js":1499464156000},"build-concat":{"./packages/hopp-plugin-concat/lib/index.js":1499464156000},"build-eslint":{"./packages/hopp-plugin-eslint/lib/index.js":1499464156000},"build-babel":{"./packages/hopp-plugin-babel/lib/index.js":1499464156000},"build-notify":{"./packages/hopp-plugin-notify/lib/index.js":1499464156000},"hopp-legacy":{"./packages/hopp/src/cache.js":1499221452000,"./packages/hopp/src/compat/else.js":1499447625000,"./packages/hopp/src/fs/get-path.js":1499150171000,"./packages/hopp/src/fs/glob.js":1499318099000,"./packages/hopp/src/fs/index.js":1499221452000,"./packages/hopp/src/hopp.js":1499318099000,"./packages/hopp/src/hoppfile/find.js":1499221452000,"./packages/hopp/src/hoppfile/index.js":1499150171000,"./packages/hopp/src/hoppfile/load.js":1499221452000,"./packages/hopp/src/index.js":1499293987000,"./packages/hopp/src/streams/buffer.js":1499150171000,"./packages/hopp/src/streams/bundle.js":1499221452000,"./packages/hopp/src/streams/index.js":1499150171000,"./packages/hopp/src/streams/map.js":1499150171000,"./packages/hopp/src/streams/readstream.js":1499294007000,"./packages/hopp/src/tasks/goal.js":1499318099000,"./packages/hopp/src/tasks/loadPlugins.js":1499293987000,"./packages/hopp/src/tasks/mgr.js":1499463285000,"./packages/hopp/src/tasks/parallel.js":1499318099000,"./packages/hopp/src/tasks/steps.js":1499318099000,"./packages/hopp/src/tasks/tree.js":1499150171000,"./packages/hopp/src/tasks/watch.js":1499150171000,"./packages/hopp/src/utils/_.js":1499150171000,"./packages/hopp/src/utils/deep-equal.js":1499150171000,"./packages/hopp/src/utils/error.js":1499318099000,"./packages/hopp/src/utils/fn.js":1499221452000,"./packages/hopp/src/utils/index.js":1499318099000,"./packages/hopp/src/utils/log.js":1499221452000}}} \ No newline at end of file +{"v":"1.2.6","p":{"hopp-plugin-eslint":{},"hopp-plugin-babel":{}},"pl":[1499539762000,{"hopp-plugin-babel":["config","default"],"hopp-plugin-eslint":["config","format","failOnError","default"]}],"lp":{"hopp-plugin-babel":"/Users/rockliang/Desktop/Project/hopp_open_source/hopp/packages/hopp-plugin-babel","hopp-plugin-eslint":"/Users/rockliang/Desktop/Project/hopp_open_source/hopp/packages/hopp-plugin-eslint"},"_":[0,null],"sc":{"lint-accord":{"./packages/hopp-plugin-accord/lib/index.js":1499625583000},"lint-babel":{"./packages/hopp-plugin-babel/lib/index.js":1499625583000},"lint-concat":{"./packages/hopp-plugin-concat/lib/index.js":1499651076000},"lint-notify":{"./packages/hopp-plugin-notify/lib/index.js":1499625583000},"lint-eslint":{"./packages/hopp-plugin-eslint/lib/index.js":1499625583000},"hopp-latest":{"./packages/hopp/src/cache.js":1499539762000,"./packages/hopp/src/compat/else.js":1499539762000,"./packages/hopp/src/fs/get-path.js":1499539762000,"./packages/hopp/src/fs/glob.js":1499539762000,"./packages/hopp/src/fs/index.js":1499539762000,"./packages/hopp/src/hopp.js":1499539762000,"./packages/hopp/src/hoppfile/find.js":1499539762000,"./packages/hopp/src/hoppfile/index.js":1499539762000,"./packages/hopp/src/hoppfile/load.js":1499539762000,"./packages/hopp/src/index.js":1499539762000,"./packages/hopp/src/streams/buffer.js":1499539762000,"./packages/hopp/src/streams/bundle.js":1499539762000,"./packages/hopp/src/streams/index.js":1499539762000,"./packages/hopp/src/streams/map.js":1499539762000,"./packages/hopp/src/streams/readstream.js":1499539762000,"./packages/hopp/src/tasks/goal.js":1499539762000,"./packages/hopp/src/tasks/loadPlugins.js":1499539762000,"./packages/hopp/src/tasks/mgr.js":1499539762000,"./packages/hopp/src/tasks/parallel.js":1499539762000,"./packages/hopp/src/tasks/steps.js":1499539762000,"./packages/hopp/src/tasks/tree.js":1499539762000,"./packages/hopp/src/tasks/watch.js":1499539762000,"./packages/hopp/src/utils/_.js":1499539762000,"./packages/hopp/src/utils/deep-equal.js":1499539762000,"./packages/hopp/src/utils/error.js":1499539762000,"./packages/hopp/src/utils/fn.js":1499539762000,"./packages/hopp/src/utils/index.js":1499539762000,"./packages/hopp/src/utils/log.js":1499539762000},"build-accord":{"./packages/hopp-plugin-accord/lib/index.js":1499625583000},"build-concat":{"./packages/hopp-plugin-concat/lib/index.js":1499651076000},"build-eslint":{"./packages/hopp-plugin-eslint/lib/index.js":1499625583000},"build-babel":{"./packages/hopp-plugin-babel/lib/index.js":1499625583000},"build-notify":{"./packages/hopp-plugin-notify/lib/index.js":1499625583000},"hopp-legacy":{"./packages/hopp/src/cache.js":1499539762000,"./packages/hopp/src/compat/else.js":1499539762000,"./packages/hopp/src/fs/get-path.js":1499539762000,"./packages/hopp/src/fs/glob.js":1499539762000,"./packages/hopp/src/fs/index.js":1499539762000,"./packages/hopp/src/hopp.js":1499539762000,"./packages/hopp/src/hoppfile/find.js":1499539762000,"./packages/hopp/src/hoppfile/index.js":1499539762000,"./packages/hopp/src/hoppfile/load.js":1499539762000,"./packages/hopp/src/index.js":1499539762000,"./packages/hopp/src/streams/buffer.js":1499539762000,"./packages/hopp/src/streams/bundle.js":1499539762000,"./packages/hopp/src/streams/index.js":1499539762000,"./packages/hopp/src/streams/map.js":1499539762000,"./packages/hopp/src/streams/readstream.js":1499539762000,"./packages/hopp/src/tasks/goal.js":1499539762000,"./packages/hopp/src/tasks/loadPlugins.js":1499539762000,"./packages/hopp/src/tasks/mgr.js":1499539762000,"./packages/hopp/src/tasks/parallel.js":1499539762000,"./packages/hopp/src/tasks/steps.js":1499539762000,"./packages/hopp/src/tasks/tree.js":1499539762000,"./packages/hopp/src/tasks/watch.js":1499539762000,"./packages/hopp/src/utils/_.js":1499539762000,"./packages/hopp/src/utils/deep-equal.js":1499539762000,"./packages/hopp/src/utils/error.js":1499539762000,"./packages/hopp/src/utils/fn.js":1499539762000,"./packages/hopp/src/utils/index.js":1499539762000,"./packages/hopp/src/utils/log.js":1499539762000}}} \ No newline at end of file diff --git a/packages/hopp-plugin-babel/.vscode/settings.json b/packages/hopp-plugin-babel/.vscode/settings.json new file mode 100644 index 0000000..3b66410 --- /dev/null +++ b/packages/hopp-plugin-babel/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.ignoreLimitWarning": true +} \ No newline at end of file diff --git a/packages/hopp-plugin-concat/dist/index.js b/packages/hopp-plugin-concat/dist/index.js index 48546ab..f245a7e 100644 --- a/packages/hopp-plugin-concat/dist/index.js +++ b/packages/hopp-plugin-concat/dist/index.js @@ -10,7 +10,7 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a * @file index.src.js * @license MIT */ - +var tmp = false; /** * For node v4. */ @@ -25,17 +25,59 @@ var config = exports.config = { /** * We don't need to do any real transformation. + * suffix and prefix features */ }; exports.default = function () { var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(ctx, data) { + var opts; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: + if (!(ctx.args.length > 1)) { + _context.next = 2; + break; + } + + throw new Error('Unexpected numbers of arguments.'); + + case 2: + + /** + * options assign + * @param suffix adding string at the end of the each file + * @param prefix adding string at the beginning of the first packet + */ + opts = ctx.args[0] || {}; + // // prefix + // if (opts.prefix && !tmp) { + // data.size += opts.prefix.length + // data.body = opts.prefix + data.body.toString(); + // } + // // suffix + // if (opts.suffix && !tmp) { + // data.size += opts.prefix.length + // data.body = data.body.toString() + opts.suffix + // } + + if (config.bundle && !tmp) { + // prefix + if (opts.prefix) { + data.size += opts.prefix.length; + data.body = opts.prefix + data.body.toString(); + } + // suffix + if (opts.suffix) { + data.size += opts.suffix.length; + data.body = data.body.toString() + opts.suffix; + } + tmp = true; + } + return _context.abrupt('return', data); - case 1: + case 5: case 'end': return _context.stop(); } diff --git a/packages/hopp-plugin-concat/dist/index.js.map b/packages/hopp-plugin-concat/dist/index.js.map index d570ff8..92b0585 100644 --- a/packages/hopp-plugin-concat/dist/index.js.map +++ b/packages/hopp-plugin-concat/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../lib/index.js"],"names":["require","config","mode","bundle","ctx","data"],"mappings":";;;;;;;;AAAA;;;;;AAKA;;;AAGAA,QAAQ,6BAAR;;AAEA;;;AAGO,IAAMC,0BAAS;AACpBC,QAAM,QADc;AAEpBC,UAAQ;;AAGV;;;AALsB,CAAf;;uDAQQ,iBAAOC,GAAP,EAAYC,IAAZ;AAAA;AAAA;AAAA;AAAA;AAAA,6CACNA,IADM;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","file":"../lib/index.js","sourcesContent":["/**\n * @file index.src.js\n * @license MIT\n */\n\n/**\n * For node v4.\n */\nrequire('regenerator-runtime/runtime')\n\n/**\n * This enables the concatenation.\n */\nexport const config = {\n mode: 'buffer',\n bundle: true\n}\n\n/**\n * We don't need to do any real transformation.\n */\nexport default async (ctx, data) => {\n return data\n}\n"]} \ No newline at end of file +{"version":3,"sources":["../lib/index.js"],"names":["tmp","require","config","mode","bundle","ctx","data","args","length","Error","opts","prefix","size","body","toString","suffix"],"mappings":";;;;;;;;AAAA;;;;AAIA,IAAIA,MAAM,KAAV;AACA;;;AAGAC,QAAQ,6BAAR;;AAEA;;;AAGO,IAAMC,0BAAS;AACpBC,QAAM,QADc;AAEpBC,UAAQ;;AAGV;;;;AALsB,CAAf;;uDASQ,iBAAOC,GAAP,EAAYC,IAAZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAITD,IAAIE,IAAJ,CAASC,MAAT,GAAkB,CAJT;AAAA;AAAA;AAAA;;AAAA,kBAKL,IAAIC,KAAJ,CAAU,kCAAV,CALK;;AAAA;;AAQb;;;;;AAKMC,gBAbO,GAaAL,IAAIE,IAAJ,CAAS,CAAT,KAAe,EAbf;AAcb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,gBAAIL,OAAOE,MAAP,IAAiB,CAACJ,GAAtB,EAA2B;AACzB;AACA,kBAAIU,KAAKC,MAAT,EAAiB;AACfL,qBAAKM,IAAL,IAAaF,KAAKC,MAAL,CAAYH,MAAzB;AACAF,qBAAKO,IAAL,GAAYH,KAAKC,MAAL,GAAcL,KAAKO,IAAL,CAAUC,QAAV,EAA1B;AACD;AACD;AACA,kBAAIJ,KAAKK,MAAT,EAAiB;AACfT,qBAAKM,IAAL,IAAaF,KAAKK,MAAL,CAAYP,MAAzB;AACAF,qBAAKO,IAAL,GAAYP,KAAKO,IAAL,CAAUC,QAAV,KAAuBJ,KAAKK,MAAxC;AACD;AACDf,oBAAM,IAAN;AACD;;AArCY,6CAuCNM,IAvCM;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","file":"../lib/index.js","sourcesContent":["/**\n * @file index.src.js\n * @license MIT\n */\nlet tmp = false\n/**\n * For node v4.\n */\nrequire('regenerator-runtime/runtime')\n\n/**\n * This enables the concatenation.\n */\nexport const config = {\n mode: 'buffer',\n bundle: true\n}\n\n/**\n * We don't need to do any real transformation.\n * suffix and prefix features\n */\nexport default async (ctx, data) => {\n /**\n * unexpected num of arguments handling\n */\n if (ctx.args.length > 1) {\n throw new Error('Unexpected numbers of arguments.')\n }\n\n /**\n * options assign\n * @param suffix adding string at the end of the each file\n * @param prefix adding string at the beginning of the first packet\n */\n const opts = ctx.args[0] || {}\n // // prefix\n // if (opts.prefix && !tmp) {\n // data.size += opts.prefix.length\n // data.body = opts.prefix + data.body.toString();\n // }\n // // suffix \n // if (opts.suffix && !tmp) {\n // data.size += opts.prefix.length\n // data.body = data.body.toString() + opts.suffix\n // }\n\n if (config.bundle && !tmp) {\n // prefix\n if (opts.prefix) {\n data.size += opts.prefix.length\n data.body = opts.prefix + data.body.toString()\n }\n // suffix\n if (opts.suffix) {\n data.size += opts.suffix.length\n data.body = data.body.toString() + opts.suffix\n }\n tmp = true\n }\n\n return data\n}\n"]} \ No newline at end of file diff --git a/packages/hopp-plugin-concat/example/.gitignore b/packages/hopp-plugin-concat/example/.gitignore index cb5256a..c25464b 100644 --- a/packages/hopp-plugin-concat/example/.gitignore +++ b/packages/hopp-plugin-concat/example/.gitignore @@ -1,2 +1,3 @@ +.vscode hopp.lock dist \ No newline at end of file diff --git a/packages/hopp-plugin-concat/example/hoppfile.js b/packages/hopp-plugin-concat/example/hoppfile.js index dcffd39..1554c0f 100644 --- a/packages/hopp-plugin-concat/example/hoppfile.js +++ b/packages/hopp-plugin-concat/example/hoppfile.js @@ -4,5 +4,7 @@ hopp.load(`${__dirname}/../`) exports.default = hopp('src/*.js') - .concat() - .dest('dist') + .concat({ + prefix:"@Rock" + }) + .dest('dist.lock') diff --git a/packages/hopp-plugin-concat/example/src/tmp.js b/packages/hopp-plugin-concat/example/src/tmp.js new file mode 100644 index 0000000..029afd6 --- /dev/null +++ b/packages/hopp-plugin-concat/example/src/tmp.js @@ -0,0 +1 @@ +console.log("this is opts js") \ No newline at end of file diff --git a/packages/hopp-plugin-concat/lib/index.js b/packages/hopp-plugin-concat/lib/index.js index f683676..3ca7b1f 100644 --- a/packages/hopp-plugin-concat/lib/index.js +++ b/packages/hopp-plugin-concat/lib/index.js @@ -2,7 +2,7 @@ * @file index.src.js * @license MIT */ - +let tmp = false /** * For node v4. */ @@ -18,7 +18,36 @@ export const config = { /** * We don't need to do any real transformation. + * suffix and prefix features added */ export default async (ctx, data) => { + /** + * unexpected num of arguments handling + */ + if (ctx.args.length > 1) { + throw new Error('Unexpected numbers of arguments.') + } + + /** + * options assign + * @param suffix adding string at the end of the each file + * @param prefix adding string at the beginning of the first packet + */ + const opts = ctx.args[0] || {} + + if (config.bundle && !tmp) { + // prefix + if (opts.prefix) { + data.size += opts.prefix.length + data.body = opts.prefix + data.body.toString() + } + // suffix + if (opts.suffix) { + data.size += opts.suffix.length + data.body = data.body.toString() + opts.suffix + } + tmp = true + } + return data }