Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
Merge pull request #949 from afc163/master
Browse files Browse the repository at this point in the history
update way of checking empty directory
  • Loading branch information
afc163 committed Aug 13, 2014
2 parents 0a16a71 + aaf3cdb commit 29d1142
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/spm-init
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ runTask();
*/

function runTask() {
if (file.list(process.cwd()).length > 0) {

if (!file.isEmptyDir(process.cwd())) {
console.warn(color.yellow('Existing files here, please run init command in an empty folder!'));
return;
}
console.log('Will create a spm package: ');

console.log('Creating a spm package: ');
inquirer.prompt([{
message: 'Package name',
name: 'name',
Expand Down
3 changes: 3 additions & 0 deletions lib/sdk/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ file.require = function(item) {
return module;
};

file.isEmptyDir = function(dir) {
return fs.readdirSync(dir).length <= 0;
}

function unixifyPath(filepath) {
if (process.platform === 'win32') {
Expand Down

0 comments on commit 29d1142

Please sign in to comment.