Skip to content

Commit

Permalink
Add code to create the specified directory if it doesn't exist.
Browse files Browse the repository at this point in the history
- Nide will now create a new directory for the project if the provided path doesn't exist. Directory creation will only take place when using the `init` command.
- Make some log messages more clear.
  • Loading branch information
coreh committed Jan 5, 2012
1 parent 3d9c4a2 commit c228c45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var program = require('commander');
var server = require('./server/server');
var project = require('./server/project');
var exec = require('child_process').exec
var path = require('path')
var fs = require('fs')

var packageJSON = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf-8'))
Expand Down Expand Up @@ -33,6 +34,10 @@ program
.action(function(dir){checkForDependencies(function(){
// Work around name collision caused by "password" function provided by commander
var password = program.password instanceof Function ? undefined : program.password
if (dir && !path.existsSync(dir)) {
console.log('Created `' + dir + '` directory.')
fs.mkdirSync(dir)
}
project.chdir(dir)
project.init()
project.start()
Expand Down
6 changes: 3 additions & 3 deletions server/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports.init = function() {
console.error('Error: Cannot create new project. `.nide` already exists.')
process.exit(-1)
}
console.log('Created project directory')
console.log('Created `.nide` directory')
var gitignore = ''
try {
gitignore = fs.readFileSync('.gitignore', 'utf8')
Expand All @@ -78,7 +78,7 @@ exports.init = function() {
}
fs.writeFileSync('.gitignore', gitignoreLines.join('\n') + '\n', 'utf8')
}
console.log('Added project directory to .gitignore')
console.log('Added `.nide` directory to .gitignore')
var npmignore = ''
try {
npmignore = fs.readFileSync('.npmignore', 'utf8')
Expand All @@ -92,7 +92,7 @@ exports.init = function() {
}
fs.writeFileSync('.npmignore', npmignoreLines.join('\n') + '\n', 'utf8')
}
console.log('Added project directory to .npmignore')
console.log('Added `.nide` directory to .npmignore')
try {
packageJson = fs.readFileSync('package.json', 'utf8')
} catch (e) {
Expand Down

0 comments on commit c228c45

Please sign in to comment.