Skip to content

Commit 2e6f8bb

Browse files
committed
modular approach
1 parent a66c302 commit 2e6f8bb

File tree

10 files changed

+11
-9
lines changed

10 files changed

+11
-9
lines changed

bin/docsify

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

33
const pkg = require('../package.json')
4-
const run = require('../src')
4+
const run = require('../lib')
55
const chalk = require('chalk')
66
const updateNotifier = require('update-notifier')
77

src/index.js renamed to lib/commands/init.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var fs = require('fs')
22
var cp = require('cp-file').sync
33
var chalk = require('chalk')
4-
var util = require('./util')
4+
var util = require('../util/index')
55

66
var exists = util.exists
77
var cwd = util.cwd
@@ -14,7 +14,7 @@ var replace = function (file, tpl, replace) {
1414

1515
var PKG = exists(cwd('package.json')) ? require(cwd('package.json')) : {}
1616

17-
exports.init = function (path, local, theme) {
17+
module.exports = function (path, local, theme) {
1818
path = path || '.'
1919
var msg = '\n' + chalk.green('Initialization succeeded!') + ' Please run ' +
2020
chalk.inverse(`docsify serve ${path}`) + '\n'
@@ -55,5 +55,3 @@ exports.init = function (path, local, theme) {
5555
}
5656
console.log(msg)
5757
}
58-
59-
exports.serve = require('./serve')

src/serve.js renamed to lib/commands/serve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var connect = require('connect')
33
var livereload = require('connect-livereload')
44
var lrserver = require('livereload')
55
var chalk = require('chalk')
6-
var util = require('./util')
6+
var util = require('../util/index')
77

88
var exists = util.exists
99
var resolve = util.resolve

lib/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
init: require('./commands/init'),
3+
serve: require('./commands/serve')
4+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/util.js renamed to lib/util/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports.cwd = function (path) {
77
}
88

99
exports.pwd = function (path) {
10-
return resolve(__dirname, path)
10+
return resolve(require('path').dirname(__dirname), path)
1111
}
1212

1313
exports.exists = function (path) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
},
1919
"files": [
2020
"bin",
21-
"src"
21+
"lib"
2222
],
2323
"scripts": {
24-
"test": "eslint src bin/docsify --fix"
24+
"test": "eslint lib bin/docsify --fix"
2525
},
2626
"dependencies": {
2727
"chalk": "^1.1.0",

0 commit comments

Comments
 (0)