commands/create.js
function(callback) {
      fs.readdir(args['<directory>'], function(err, files) {
        // error here means it does not exist, which is good.
        if (err || args['--force']) {
          return callback(null, args['<directory>']);
        }
        if (files.length > 0) {
          return callback(new Error(format('destination '
            + 'directory %s is not empty.', path.resolve(args['<directory>']))));
        }
        return callback(null, args['<directory>']);
      });
    }
function(callback) {
      fs.readdir(args['<directory>'], function(err, files) {
        // error here means it does not exist, which is good.
        if (err || args['--force']) {
          return callback(null, args['<directory>']);
        }
        if (files.length > 0) {
          return callback(new Error(format('destination '
            + 'directory %s is not empty.', path.resolve(args['<directory>']))));
        }
        return callback(null, args['<directory>']);
      });
    }
function ( callback ) { fs . readdir ( args [ '<directory>' ] , function ( err , files ) { // error here means it does not exist, which is good. if ( err || args [ '--force' ] ) { return callback ( null , args [ '<directory>' ] ) ; } if ( files . length > 0 ) { return callback ( new Error ( format ( 'destination ' + 'directory %s is not empty.' , path . resolve ( args [ '<directory>' ] ) ) ) ) ; } return callback ( null , args [ '<directory>' ] ) ; } ) ; }
before copying, make sure the target directory is empty or does not exist.
before copying make sure the target directory is empty or does not exist .