From 65ff3b0d2f20db03a4a41246de8d11a152bad41a Mon Sep 17 00:00:00 2001 From: Guo Yu Date: Tue, 12 May 2015 15:35:30 +0800 Subject: [PATCH] Bugfix, fix a export bug in lib cli --- dist/cli.js | 25 +++++++++++++++++++------ dist/cli.js.map | 2 +- lib/cli.js | 12 +++++++----- package.json | 3 ++- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/dist/cli.js b/dist/cli.js index fc85d46..cad93db 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -1,5 +1,11 @@ 'use strict'; +Object.defineProperty(exports, '__esModule', { + value: true +}); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _fs = require('fs'); @@ -16,21 +22,28 @@ var _consoler2 = _interopRequireDefault(_consoler); var _docor = require('./docor'); -var _docor2 = _interopRequireDefault(_docor); +var docor = _interopRequireWildcard(_docor); var files = ['README.md', 'LICENSE', '.gitignore', '.npmignore']; -var checkPackage = (function (file) { - return _fs2['default'].existsSync(_path2['default'].join(process.cwd(), file)); -})(function () { +var checkPackage = function checkPackage(f) { + return _fs2['default'].existsSync(_path2['default'].join(process.cwd(), f)); +}; + +// Add a `;` to prevent compile error. +// It's a bebel's bug ? XD + +exports['default'] = function () { if (!checkPackage('package.json')) return _consoler2['default'].error('Docor.init(); `package.json` file not found'); files.forEach(function (file) { - _docor2['default'].createFile(file, function (err) { + docor.createFile(file, function (err) { if (err) return _consoler2['default'].error(err); _consoler2['default'].success(file + ' created'); }); }); -})(); +}; + +module.exports = exports['default']; //# sourceMappingURL=cli.js.map \ No newline at end of file diff --git a/dist/cli.js.map b/dist/cli.js.map index f347aa4..d90c340 100644 --- a/dist/cli.js.map +++ b/dist/cli.js.map @@ -1 +1 @@ -{"version":3,"sources":["../lib/cli.js"],"names":[],"mappings":";;;;kBAAe,IAAI;;;;oBACF,MAAM;;;;wBACF,UAAU;;;;qBACb,SAAS;;;;AAE3B,IAAM,KAAK,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;;AAElE,IAAI,YAAY,GAAG,CAAA,UAAC,IAAI,EAAK;AAC3B,SAAO,gBAAG,UAAU,CAClB,kBAAK,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAC/B,CAAA;CACF,CAAA,CAEA,YAAM;AACL,MAAI,CAAC,YAAY,CAAC,cAAc,CAAC,EAC/B,OAAO,sBAAS,KAAK,CAAC,6CAA6C,CAAC,CAAA;;AAEtE,OAAK,CAAC,OAAO,CAAC,UAAC,IAAI,EAAK;AACtB,uBAAM,UAAU,CAAC,IAAI,EAAE,UAAC,GAAG,EAAK;AAC9B,UAAI,GAAG,EACL,OAAO,sBAAS,KAAK,CAAC,GAAG,CAAC,CAAA;;AAE5B,4BAAS,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,CAAA;KACpC,CAAC,CAAA;GACH,CAAC,CAAA;CACH,CAAC,EAAE,CAAA","file":"lib/cli.js","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport consoler from 'consoler'\nimport docor from './docor'\n\nconst files = ['README.md', 'LICENSE', '.gitignore', '.npmignore']\n\nlet checkPackage = (file) => {\n return fs.existsSync(\n path.join(process.cwd(), file)\n )\n}\n\n(() => {\n if (!checkPackage('package.json')) \n return consoler.error('Docor.init(); `package.json` file not found')\n\n files.forEach((file) => {\n docor.createFile(file, (err) => {\n if (err) \n return consoler.error(err)\n\n consoler.success(file + ' created')\n })\n })\n})()\n"]} \ No newline at end of file +{"version":3,"sources":["../lib/cli.js"],"names":[],"mappings":";;;;;;;;;;kBAAe,IAAI;;;;oBACF,MAAM;;;;wBACF,UAAU;;;;qBACR,SAAS;;IAApB,KAAK;;AAEjB,IAAM,KAAK,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;;AAElE,IAAI,YAAY,GAAG,SAAf,YAAY,CAAI,CAAC,EAAK;AACxB,SAAO,gBAAG,UAAU,CAClB,kBAAK,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAC5B,CAAA;CACF,CAAA;;;;;qBAIc,YAAW;AACxB,MAAI,CAAC,YAAY,CAAC,cAAc,CAAC,EAC/B,OAAO,sBAAS,KAAK,CAAC,6CAA6C,CAAC,CAAA;;AAEtE,OAAK,CAAC,OAAO,CAAC,UAAC,IAAI,EAAK;AACtB,SAAK,CAAC,UAAU,CAAC,IAAI,EAAE,UAAC,GAAG,EAAK;AAC9B,UAAI,GAAG,EACL,OAAO,sBAAS,KAAK,CAAC,GAAG,CAAC,CAAA;;AAE5B,4BAAS,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,CAAA;KACpC,CAAC,CAAA;GACH,CAAC,CAAA;CACH","file":"lib/cli.js","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport consoler from 'consoler'\nimport * as docor from './docor'\n\nconst files = ['README.md', 'LICENSE', '.gitignore', '.npmignore']\n\nlet checkPackage = (f) => {\n return fs.existsSync(\n path.join(process.cwd(), f)\n )\n}\n\n// Add a `;` to prevent compile error.\n// It's a bebel's bug ? XD\nexport default function() {\n if (!checkPackage('package.json')) \n return consoler.error('Docor.init(); `package.json` file not found')\n\n files.forEach((file) => {\n docor.createFile(file, (err) => {\n if (err) \n return consoler.error(err)\n\n consoler.success(file + ' created')\n })\n })\n}\n"]} \ No newline at end of file diff --git a/lib/cli.js b/lib/cli.js index 225009b..88839e2 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -1,17 +1,19 @@ import fs from 'fs' import path from 'path' import consoler from 'consoler' -import docor from './docor' +import * as docor from './docor' const files = ['README.md', 'LICENSE', '.gitignore', '.npmignore'] -let checkPackage = (file) => { +let checkPackage = (f) => { return fs.existsSync( - path.join(process.cwd(), file) + path.join(process.cwd(), f) ) } -(() => { +// Add a `;` to prevent compile error. +// It's a bebel's bug ? XD +export default function() { if (!checkPackage('package.json')) return consoler.error('Docor.init(); `package.json` file not found') @@ -23,4 +25,4 @@ let checkPackage = (file) => { consoler.success(file + ' created') }) }) -})() +} diff --git a/package.json b/package.json index f22254f..2ac618c 100755 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "license": "MIT", "bin": "bin/cli", "scripts": { - "build": "node_modules/.bin/babel lib --out-dir dist --source-maps", + "build": "node_modules/.bin/babel lib --out-dir dist --source-map", + "build": "node_modules/.bin/babel lib --out-dir dist --source-maps --watch", "example": "cd ./example && ../bin/cli" }, "repository": {