Skip to content

Commit

Permalink
2.0.3: fixes babel-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Jun 20, 2017
1 parent 61a689f commit 5aadb18
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
4 changes: 3 additions & 1 deletion index.js
Expand Up @@ -4,18 +4,20 @@ const path = require('path')
const {
glob
} = require('glob-gitignore')
const { EventEmitter } = require('events')


const REGEX_IS_GLOB_FILE = /[^\/]$/

module.exports = class Scaffold {
module.exports = class Scaffold extends EventEmitter {
constructor ({
render,
override = true,
backup = true,
data,
ignore
} = {}) {
super()

assert(render && typeof render === 'function',
'options.render must be a function.')
Expand Down
3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "scaffold-generator",
"version": "2.0.2",
"version": "2.0.3",
"description": "Generates a repo from a specified template and data.",
"main": "scaffold.js",
"scripts": {
Expand Down Expand Up @@ -53,6 +53,7 @@
"tmp": "^0.0.31"
},
"dependencies": {
"babel-runtime": "^6.23.0",
"fs-extra": "^3.0.1",
"glob-gitignore": "^1.0.4"
}
Expand Down
49 changes: 34 additions & 15 deletions scaffold.js
Expand Up @@ -16,6 +16,10 @@ var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
Expand All @@ -24,6 +28,14 @@ var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var assert = require('assert');
Expand All @@ -33,9 +45,14 @@ var path = require('path');
var _require = require('glob-gitignore'),
glob = _require.glob;

var _require2 = require('events'),
EventEmitter = _require2.EventEmitter;

var REGEX_IS_GLOB_FILE = /[^\/]$/;

module.exports = function () {
module.exports = function (_EventEmitter) {
(0, _inherits3.default)(Scaffold, _EventEmitter);

function Scaffold() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
render = _ref.render,
Expand All @@ -48,15 +65,17 @@ module.exports = function () {

(0, _classCallCheck3.default)(this, Scaffold);

var _this = (0, _possibleConstructorReturn3.default)(this, (Scaffold.__proto__ || (0, _getPrototypeOf2.default)(Scaffold)).call(this));

assert(render && typeof render === 'function', 'options.render must be a function.');
assert(Object(data) === data, 'options.data must be an object.');

this._render = render;
this._override = override;
this._backup = backup;
this._data = data;
this._ignore = ignore;
_this._render = render;
_this._override = override;
_this._backup = backup;
_this._data = data;
_this._ignore = ignore;
return _this;
}

(0, _createClass3.default)(Scaffold, [{
Expand All @@ -72,7 +91,7 @@ module.exports = function () {
key: '_copy',
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(from, to) {
var _this = this;
var _this2 = this;

var stat;
return _regenerator2.default.wrap(function _callee$(_context) {
Expand All @@ -96,13 +115,13 @@ module.exports = function () {
return _context.abrupt('return', fs.stat(to).then(function (stat) {
if (stat.isDirectory()) {
// Only substitute path when `to` is not explicitly specified.
var name = _this._to(path.basename(from));
var name = _this2._to(path.basename(from));
to = path.join(to, name);
}

return _this._copyFile(from, to);
return _this2._copyFile(from, to);
}, function () {
return _this._copyFile(from, to);
return _this2._copyFile(from, to);
}));

case 6:
Expand All @@ -123,7 +142,7 @@ module.exports = function () {
key: '_copyDir',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(from, to) {
var _this2 = this;
var _this3 = this;

var files, map;
return _regenerator2.default.wrap(function _callee2$(_context2) {
Expand All @@ -143,7 +162,7 @@ module.exports = function () {
var file_to = path.join(to, file);

// Only substitute path when `to` is not explicitly specified.
map[file_from] = _this2._to(file_to);
map[file_from] = _this3._to(file_to);
});

return _context2.abrupt('return', this._copyFiles(map));
Expand Down Expand Up @@ -207,11 +226,11 @@ module.exports = function () {
}, {
key: '_copyFiles',
value: function _copyFiles(map) {
var _this3 = this;
var _this4 = this;

var tasks = (0, _keys2.default)(map).map(function (from) {
var to = map[from];
return _this3._copyFile(from, to);
return _this4._copyFile(from, to);
});

return _promise2.default.all(tasks);
Expand Down Expand Up @@ -375,4 +394,4 @@ module.exports = function () {
}
}]);
return Scaffold;
}();
}(EventEmitter);
2 changes: 1 addition & 1 deletion test/scaffold-generator.js
Expand Up @@ -77,7 +77,7 @@ test('copy, override=false, not exists', async t => {
await equal(t, to, 'package.json')
})

test.only('copy, override=false, not exists, hierachical dirs', async t => {
test('copy, override=false, not exists, hierachical dirs', async t => {
const to = await tmp()
await s({
data: {
Expand Down

0 comments on commit 5aadb18

Please sign in to comment.