1 | 'use strict'
|
2 |
|
3 | async = require 'async'
|
4 | Semver = require './Bumped.semver'
|
5 | Config = require './Bumped.config'
|
6 | Logger = require './Bumped.logger'
|
7 | Plugin = require './Bumped.plugin'
|
8 | DEFAULT = require './Bumped.default'
|
9 | MSG = require './Bumped.messages'
|
10 |
|
11 | module.exports = class Bumped
|
12 |
|
13 | constructor: (opts = {}) ->
|
14 | process.chdir opts.cwd if opts.cwd
|
15 | @pkg = require '../package.json'
|
16 | @config = new Config this
|
17 | @semver = new Semver this
|
18 | @logger = new Logger opts.logger
|
19 | @plugin = new Plugin this
|
20 |
|
21 | this
|
22 |
|
23 | |
24 |
|
25 |
|
26 | load: ->
|
27 | [opts, cb] = DEFAULT.args arguments
|
28 |
|
29 | return cb() unless @config.rc.config
|
30 |
|
31 | tasks = [
|
32 | (next) => @config.load opts, next
|
33 | (next) => @semver.sync opts, next
|
34 | ]
|
35 |
|
36 | async.series tasks, cb
|
37 |
|
38 | |
39 |
|
40 |
|
41 | init: =>
|
42 | [opts, cb] = DEFAULT.args arguments
|
43 |
|
44 | tasks = [
|
45 | (next) => @config.autodetect opts, next
|
46 | (next) => @config.save opts, next
|
47 | (next) => @semver.sync opts, next
|
48 | ]
|
49 |
|
50 | async.waterfall tasks, (err, result) =>
|
51 | return @logger.errorHandler err, cb if err
|
52 | @end opts, cb
|
53 |
|
54 | end: ->
|
55 | [opts, cb] = DEFAULT.args arguments
|
56 |
|
57 | @semver.version opts, =>
|
58 | @logger.success MSG.CONFIG_CREATED()
|
59 | cb()
|