Socket
Socket
Sign inDemoInstall

build-ignore

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-ignore - npm Package Compare versions

Comparing version 1.1.13 to 1.2.0

.eslintrc

10

package.json
{
"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"
}
}

40

src/index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc