Skip to content

Commit

Permalink
Merge 2f54f66 into a319889
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAdam committed Apr 1, 2014
2 parents a319889 + 2f54f66 commit 12e6495
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/dest/index.js
Expand Up @@ -7,17 +7,22 @@ var writeContents = require('./writeContents');
var defaultMode = 0777 & (~process.umask());

module.exports = function(outFolder, opt) {
if (typeof outFolder !== 'string') throw new Error('Invalid output folder');

if (!opt) opt = {};
if (!opt.cwd) opt.cwd = process.cwd();
if (typeof opt.mode === 'string') opt.mode = parseInt(opt.mode, 8);

var cwd = path.resolve(opt.cwd);
var basePath = path.resolve(cwd, outFolder);
var folderMode = (opt.mode || defaultMode);
var basePath;

if (typeof outFolder === 'string') {
basePath = path.resolve(cwd, outFolder);
} else if (typeof outFolder !== 'function') {
throw new Error('Invalid output folder');
}

function saveFile (file, cb) {
if (typeof outFolder === 'function') basePath = path.resolve(cwd, outFolder(file));
var writePath = path.resolve(basePath, file.relative);
var writeFolder = path.dirname(writePath);

Expand Down

0 comments on commit 12e6495

Please sign in to comment.