Skip to content
Browse files

Nide now adds itself to .gitignore and .npmignore files on project in…

…itialization.
  • Loading branch information...
1 parent 6b4f1e4 commit 5cf943ce5b4351c9c57eaec5420b85d81f73d228 @coreh coreh committed Aug 28, 2011
Showing with 28 additions and 1 deletion.
  1. +1 −1 .gitignore
  2. +1 −0 .npmignore
  3. +26 −0 project.js
View
2 .gitignore
@@ -1,3 +1,3 @@
-.nide
node_modules
.DS_Store
+.nide
View
1 .npmignore
@@ -0,0 +1 @@
+.nide
View
26 project.js
@@ -62,6 +62,32 @@ exports.init = function() {
console.error('Error: Cannot create new project. `.nide` already exists.')
process.exit(-1)
}
+ var gitignore = ''
+ try {
+ gitignore = fs.readFileSync('.gitignore', 'utf8')
+ } catch (e) {}
+ var gitignoreLines = gitignore.split('\n')
+ if (gitignoreLines.indexOf('.nide') == -1) {
+ if (gitignoreLines[gitignoreLines.length-1] == '') {
+ gitignoreLines[gitignoreLines.length-1] = '.nide'
+ } else {
+ gitignoreLines.push('.nide')
+ }
+ fs.writeFileSync('.gitignore', gitignoreLines.join('\n') + '\n', 'utf8')
+ }
+ var npmignore = ''
+ try {
+ npmignore = fs.readFileSync('.npmignore', 'utf8')
+ } catch (e) {}
+ var npmignoreLines = npmignore.split('\n')
+ if (npmignoreLines.indexOf('.nide') == -1) {
+ if (npmignoreLines[npmignoreLines.length-1] == '') {
+ npmignoreLines[npmignoreLines.length-1] = '.nide'
+ } else {
+ npmignoreLines.push('.nide')
+ }
+ fs.writeFileSync('.npmignore', npmignoreLines.join('\n') + '\n', 'utf8')
+ }
}
exports.chdir = function(dir) {

0 comments on commit 5cf943c

Please sign in to comment.
Something went wrong with that request. Please try again.