2
2
var assert = require ( 'assert' )
3
3
var clone = require ( 'clone' )
4
4
var fs = require ( 'co-fs-extra' )
5
- var is = require ( 'is' )
6
5
var matter = require ( 'gray-matter' )
7
6
var Mode = require ( 'stat-mode' )
8
7
var path = require ( 'path' )
@@ -25,7 +24,11 @@ rm = thunkify(rm)
25
24
* Helpers
26
25
*/
27
26
28
- var absolute = function ( s ) { return path . resolve ( s ) === s }
27
+ var absolute = function ( s ) { return path . resolve ( s ) === s }
28
+ var isBoolean = function ( b ) { return typeof b === 'boolean' }
29
+ var isNumber = function ( n ) { return typeof n === 'number' && ! Number . isNaN ( n ) }
30
+ var isObject = function ( o ) { return o !== null && typeof o === 'object' }
31
+ var isString = function ( s ) { return typeof s === 'string' }
29
32
30
33
31
34
/**
@@ -75,7 +78,7 @@ Metalsmith.prototype.use = function(plugin){
75
78
76
79
Metalsmith . prototype . directory = function ( directory ) {
77
80
if ( ! arguments . length ) return path . resolve ( this . _directory )
78
- assert ( is . string ( directory ) , 'You must pass a directory path string.' )
81
+ assert ( isString ( directory ) , 'You must pass a directory path string.' )
79
82
this . _directory = directory
80
83
return this
81
84
}
@@ -89,7 +92,7 @@ Metalsmith.prototype.directory = function(directory){
89
92
90
93
Metalsmith . prototype . metadata = function ( metadata ) {
91
94
if ( ! arguments . length ) return this . _metadata
92
- assert ( is . object ( metadata ) , 'You must pass a metadata object.' )
95
+ assert ( isObject ( metadata ) , 'You must pass a metadata object.' )
93
96
this . _metadata = clone ( metadata )
94
97
return this
95
98
}
@@ -103,7 +106,7 @@ Metalsmith.prototype.metadata = function(metadata){
103
106
104
107
Metalsmith . prototype . source = function ( path ) {
105
108
if ( ! arguments . length ) return this . path ( this . _source )
106
- assert ( is . string ( path ) , 'You must pass a source path string.' )
109
+ assert ( isString ( path ) , 'You must pass a source path string.' )
107
110
this . _source = path
108
111
return this
109
112
}
@@ -117,7 +120,7 @@ Metalsmith.prototype.source = function(path){
117
120
118
121
Metalsmith . prototype . destination = function ( path ) {
119
122
if ( ! arguments . length ) return this . path ( this . _destination )
120
- assert ( is . string ( path ) , 'You must pass a destination path string.' )
123
+ assert ( isString ( path ) , 'You must pass a destination path string.' )
121
124
this . _destination = path
122
125
return this
123
126
}
@@ -131,7 +134,7 @@ Metalsmith.prototype.destination = function(path){
131
134
132
135
Metalsmith . prototype . concurrency = function ( max ) {
133
136
if ( ! arguments . length ) return this . _concurrency
134
- assert ( is . number ( max ) , 'You must pass a number for concurrency.' )
137
+ assert ( isNumber ( max ) , 'You must pass a number for concurrency.' )
135
138
this . _concurrency = max
136
139
return this
137
140
}
@@ -144,7 +147,7 @@ Metalsmith.prototype.concurrency = function(max){
144
147
*/
145
148
Metalsmith . prototype . clean = function ( clean ) {
146
149
if ( ! arguments . length ) return this . _clean
147
- assert ( is . boolean ( clean ) , 'You must pass a boolean.' )
150
+ assert ( isBoolean ( clean ) , 'You must pass a boolean.' )
148
151
this . _clean = clean
149
152
return this
150
153
}
@@ -158,7 +161,7 @@ Metalsmith.prototype.clean = function(clean){
158
161
159
162
Metalsmith . prototype . frontmatter = function ( frontmatter ) {
160
163
if ( ! arguments . length ) return this . _frontmatter
161
- assert ( is . boolean ( frontmatter ) , 'You must pass a boolean.' )
164
+ assert ( isBoolean ( frontmatter ) , 'You must pass a boolean.' )
162
165
this . _frontmatter = frontmatter
163
166
return this
164
167
}
0 commit comments