Skip to content

Commit

Permalink
Resolves #352: calling Metalsmith() without args defaults metalsmith.…
Browse files Browse the repository at this point in the history
…directory to process.cwd()
  • Loading branch information
webketje committed Dec 19, 2021
1 parent acd9a4c commit b7a63ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = Metalsmith

function Metalsmith(directory){
if (!(this instanceof Metalsmith)) return new Metalsmith(directory)
assert(directory, 'You must pass a working directory path.')
if (!directory) directory = process.cwd()
this.plugins = []
this.ignores = []
this.directory(directory)
Expand Down
7 changes: 3 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ describe('Metalsmith', function(){
assert(m instanceof Metalsmith)
})

it('should error without a working directory', function(){
assert.throws(function(){
Metalsmith()
}, /You must pass a working directory path\./)
it('should default to process.cwd() if a working directory path is not specified', function(){
var m = Metalsmith()
assert.strictEqual(m.directory(), process.cwd())
})

it('should use `./src` as a default source directory', function(){
Expand Down

0 comments on commit b7a63ba

Please sign in to comment.