build-ignore
Advanced tools
Comparing version 1.1.13 to 1.2.0
{ | ||
"name": "build-ignore", | ||
"version": "1.1.13", | ||
"version": "1.2.0", | ||
"description": "A post-checkout hook script that generates branch specific .gitignore files", | ||
@@ -10,2 +10,5 @@ "main": "src/index.js", | ||
}, | ||
"scripts": { | ||
"test": "eslint ./src/index.js" | ||
}, | ||
"keywords": [ | ||
@@ -20,3 +23,6 @@ "git", | ||
"author": "David Conner <david@david-conner.com>", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"devDependencies": { | ||
"eslint": "^3.19.0" | ||
} | ||
} |
@@ -7,31 +7,27 @@ #!/usr/bin/env node | ||
const path = require('path'); | ||
const regEx = /ref: refs\/heads\/([^\n]+)/; | ||
const gitBranch = function() { | ||
fs.readFile(`${path.join(process.cwd(), '.git/HEAD')}`, 'utf8', (err, data) => { | ||
//if error in getting | ||
if (err) throw err; | ||
const readInWriteOut = (branch) => { | ||
fs.readFile(path.join(process.cwd(),`gitignores/gitignore_${branch}.txt`), 'utf8', (err, data) => { | ||
fs.writeFile(path.join(process.cwd(), '.gitignore'), data, (err) => { | ||
if (err) { throw err; } | ||
console.log(`New .gitignore created from ${branch}:\n`, data); | ||
}); | ||
}); | ||
}; | ||
const gitBranch = () => { | ||
fs.readFile(path.join(process.cwd(), `.git/HEAD`), 'utf8', (err, data) => { | ||
if (err) { throw err; } | ||
const match = regEx.exec(data); | ||
const doesExist = fs.existsSync(`gitignores/gitignore_${match[1]}.txt`); | ||
if (match) { | ||
if (fs.existsSync(`gitignores/gitignore_${match[1]}.txt`)) { | ||
fs.readFile(path.join(process.cwd(), `gitignores/gitignore_${match[1]}.txt`), 'utf8', (err, data) => { | ||
fs.writeFile('./.gitignore', data, (err) => { | ||
if (err) throw err; | ||
}); | ||
console.log(`New .gitignore created on ${match[1]}: \n`, data); | ||
}); | ||
} else { | ||
fs.readFile(path.join(process.cwd(),'gitignores/gitignore_master.txt'), 'utf8', (err, data) => { | ||
fs.writeFile('./.gitignore', data, (err) => { | ||
if (err) throw err; | ||
console.log('It\'s saved!'); | ||
}); | ||
console.log(`New .gitignore created from master: \n`, data); | ||
}); | ||
} | ||
readInWriteOut(doesExist ? match[1] : 'master'); | ||
} else { | ||
console.log('Somethingwent wrong!!'); | ||
console.log('Something went wrong!!'); | ||
} | ||
}); | ||
} | ||
}; | ||
module.exports = gitBranch; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32948
9
1
29