Skip to content

Commit 1ec86f8

Browse files
author
Jeff Escalante
committed
Merge pull request #142 from static-dev/event-naming
Switch up the event naming a bit
2 parents 25aa80e + a9bed4f commit 1ec86f8

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

lib/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Spike.template = {
208208

209209
emit('info', 'adding template')
210210
sprout.add(opts.name, opts.src).done(() => {
211-
emit('done', `template "${opts.name}" added`)
211+
emit('success', `template "${opts.name}" added`)
212212
}, (err) => {
213213
emit('error', err)
214214
})
@@ -219,7 +219,7 @@ Spike.template = {
219219
* @param {String} name - name of the template to remove
220220
* @param {EventEmitter} emitter - will return events to report progress
221221
* @fires emitter#info
222-
* @fires emitter#done
222+
* @fires emitter#success
223223
*/
224224
remove: function (options = {}) {
225225
const schema = Joi.object().keys({
@@ -230,7 +230,7 @@ Spike.template = {
230230

231231
emit('info', 'removing template')
232232
sprout.remove(opts.name).done(() => {
233-
emit('done', `template "${opts.name}" removed`)
233+
emit('success', `template "${opts.name}" removed`)
234234
})
235235
},
236236
/**
@@ -239,7 +239,7 @@ Spike.template = {
239239
* @param {String} name - name of the template to make default
240240
* @param {EventEmitter} [emitter] - will return events to report progress
241241
* @fires emitter#info
242-
* @fires emitter#done
242+
* @fires emitter#success
243243
* @fires emitter#error
244244
*/
245245
default: function (options = {}) {
@@ -253,7 +253,7 @@ Spike.template = {
253253
if (tpl) {
254254
writeConfig({ defaultTemplate: { name: tpl.name, src: tpl.src } })
255255
const message = `template "${opts.name}" is now the default`
256-
emit('done', message)
256+
emit('success', message)
257257
return message
258258
} else {
259259
const message = `template "${opts.name}" doesn't exist`
@@ -265,15 +265,15 @@ Spike.template = {
265265
* Sets a template as the default when creating projects with `Spike.new`
266266
* @param {EventEmitter} [emitter] - will return events to report progress
267267
* @fires emitter#info
268-
* @fires emitter#done
268+
* @fires emitter#success
269269
*/
270270
list: function (options = {}) {
271271
const schema = Joi.object().keys({
272272
emitter: Joi.func().default({ emit: (x) => x })
273273
})
274274
const {emit, sprout} = this._init(options, schema)
275275

276-
emit('done', sprout.templates)
276+
emit('success', sprout.templates)
277277
return sprout.templates
278278
},
279279
/**

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const emitter = new EventEmitter()
139139

140140
emitter.on('info', console.log)
141141
emitter.on('error', console.error)
142-
emitter.on('done', console.log)
142+
emitter.on('success', console.log)
143143

144144
Spike.template.add({
145145
name: 'test',
@@ -157,7 +157,7 @@ const EventEmitter = require('events')
157157
const emitter = new EventEmitter()
158158

159159
emitter.on('info', console.log)
160-
emitter.on('done', console.log)
160+
emitter.on('success', console.log)
161161

162162
Spike.template.remove({ name: 'test' emitter: emitter })
163163
```
@@ -172,7 +172,7 @@ const emitter = new EventEmitter()
172172

173173
emitter.on('info', console.log)
174174
emitter.on('error', console.log)
175-
emitter.on('done', console.log)
175+
emitter.on('success', console.log)
176176

177177
Spike.template.default({ name: 'test' emitter: emitter })
178178
```
@@ -193,7 +193,7 @@ const EventEmitter = require('events')
193193
const emitter = new EventEmitter()
194194

195195
emitter.on('info', console.log)
196-
emitter.on('done', console.log)
196+
emitter.on('success', console.log)
197197

198198
Spike.template.list({ emitter: emitter })
199199
```

test/new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test.cb('creates a new project with a custom template', (t) => {
3737
const e2 = new EventEmitter()
3838

3939
e1.on('info', debug)
40-
e1.on('done', (res) => {
40+
e1.on('success', (res) => {
4141
Spike.new({
4242
root: testPath,
4343
emitter: e2,

test/template.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const EventEmitter = require('events')
33
const path = require('path')
44
const fs = require('fs')
55
const rimraf = require('rimraf')
6-
const {fixturesPath} = require('./_helpers')
6+
const {fixturesPath, debug} = require('./_helpers')
77
const Spike = require('..')
88

99
test.before((t) => { Spike.template.reset() })
@@ -12,9 +12,9 @@ test.afterEach((t) => { Spike.template.reset() })
1212
test.cb('template.add adds a template', (t) => {
1313
const emitter = new EventEmitter()
1414

15-
emitter.on('info', console.log)
15+
emitter.on('info', debug)
1616

17-
emitter.on('done', (res) => {
17+
emitter.on('success', (res) => {
1818
t.truthy(res === 'template "test" added')
1919
t.truthy(Object.keys(Spike.template.list()).indexOf('test') > -1)
2020
t.end()
@@ -31,14 +31,14 @@ test.cb('template.remove gets rid of a template', (t) => {
3131
const e1 = new EventEmitter()
3232
const e2 = new EventEmitter()
3333

34-
e1.on('info', console.log)
35-
e2.on('info', console.log)
34+
e1.on('info', debug)
35+
e2.on('info', debug)
3636

37-
e1.on('done', (res) => {
37+
e1.on('success', (res) => {
3838
Spike.template.remove({ name: 'test', emitter: e2 })
3939
})
4040

41-
e2.on('done', (res) => {
41+
e2.on('success', (res) => {
4242
t.truthy(res === 'template "test" removed')
4343
t.falsy(Object.keys(Spike.template.list()).indexOf('test') > -1)
4444
t.end()
@@ -57,15 +57,15 @@ test.cb('template.default sets the default template', (t) => {
5757
const e3 = new EventEmitter()
5858
const testPath = path.join(fixturesPath, 'new_test')
5959

60-
e1.on('info', console.log)
61-
e2.on('info', console.log)
62-
e3.on('info', console.log)
60+
e1.on('info', debug)
61+
e2.on('info', debug)
62+
e3.on('info', debug)
6363

64-
e1.on('done', (res) => {
64+
e1.on('success', (res) => {
6565
Spike.template.default({ name: 'test', emitter: e2 })
6666
})
6767

68-
e2.on('done', (res) => {
68+
e2.on('success', (res) => {
6969
t.truthy(res === 'template "test" is now the default')
7070
Spike.new({
7171
root: testPath,

0 commit comments

Comments
 (0)