Skip to content

Commit

Permalink
Merge pull request #1177 from donejs/scoped-projects
Browse files Browse the repository at this point in the history
Handle creating folder structure for scoped projects
  • Loading branch information
Mattchewone committed Apr 24, 2019
2 parents 42c091e + e330a24 commit a21e76b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ exports.mkdirp = function(folder) {
var dfd = Q();
var current = '';

parts.forEach(function(part) {
var myPath = path.join(current, part);

current = myPath;

var resolve = function() {
return myPath;
};

dfd = dfd.then(function() {
return Q.nfcall(fs.mkdir, myPath).then(resolve, resolve);
});
parts.forEach(function(part, index) {
// If we are using scoped names like "@bitovi/my-plugin"
// Only create the folder for "my-plugin" and exclude the scoping
if ((index === 0 && part.indexOf('@') === -1) || index > 0) {
var myPath = path.join(current, part);

current = myPath;

var resolve = function() {
return myPath;
};

dfd = dfd.then(function() {
return Q.nfcall(fs.mkdir, myPath).then(resolve, resolve);
});
}
});

return dfd.then(function(myPath) {
Expand Down
7 changes: 7 additions & 0 deletions test/utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ describe('utils tests', function() {
assert.equal(folderPath, process.cwd());
});
});

it('mkdirp ignores scoped project name', function() {
return utils.mkdirp('@bitovi/test')
.then(function(folderPath) {
assert.equal(folderPath, path.join(process.cwd(), 'test'));
});
});

it('spawns successfully', function(done) {
var cwd = path.join(__dirname, '..');
Expand Down

0 comments on commit a21e76b

Please sign in to comment.