build-ignore
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "build-ignore", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A post-checkout hook script that generates a .gitignore based on branch name for when different .gitignores are needed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
#!/usr/bin/env node | ||
(function () { | ||
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
exports.gitBranch = gitBranch = function(branch) { | ||
const currentBranch = branch || process.argv[2] | ||
const regEx = /ref: refs\/heads\/([^\n]+)/; | ||
fs.readFile(`${path.join(process.cwd(), '.git/HEAD')}`, 'utf8', (err, data) => { | ||
//if error in getting | ||
if (err) throw err; | ||
const match = regEx.exec(data); | ||
if (match) { | ||
if (match[1] === branch) { | ||
console.log('Shit is legit yoooooo', match[1]); | ||
fs.readFile(path.join(process.cwd(),'gitignores/gitignore_publish.txt'), 'utf8', (err, data) => { | ||
fs.writeFile('./.gitignore', data, (err) => { | ||
if (err) throw err; | ||
console.log('It\'s saved!'); | ||
}); | ||
console.log('DATA', 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('DATA', data); | ||
}); | ||
} | ||
} | ||
}); | ||
}; | ||
}).call(this); | ||
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const currentBranch = process.argv[2] | ||
const regEx = /ref: refs\/heads\/([^\n]+)/; | ||
fs.readFile(`${path.join(process.cwd(), '.git/HEAD')}`, 'utf8', (err, data) => { | ||
//if error in getting | ||
if (err) throw err; | ||
const match = regEx.exec(data); | ||
if (match) { | ||
if (match[1] === currentBranch) { | ||
console.log('Shit is legit yoooooo', match[1]); | ||
fs.readFile(path.join(process.cwd(),'gitignores/gitignore_publish.txt'), 'utf8', (err, data) => { | ||
fs.writeFile('./.gitignore', data, (err) => { | ||
if (err) throw err; | ||
console.log('It\'s saved!'); | ||
}); | ||
console.log('DATA', 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('DATA', data); | ||
}); | ||
} | ||
} | ||
}); |
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
1663
31