Skip to content

Commit

Permalink
Fix the NPM package.json file, format code
Browse files Browse the repository at this point in the history
- remove all the information required for public packages
- change the link to the URL
- remove redundant node versions from the travic CONF file
- Autoformat the code according to semistandard

Signed-off-by: Siddharth Kannan <[email protected]>
  • Loading branch information
Siddharth Kannan committed Feb 11, 2016
1 parent 2bfb787 commit 02f93ad
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 68 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ sudo: false
language: node_js
script: node test.js
node_js:
- 'iojs'
- '0.12'
- '0.10'
15 changes: 3 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@
"description": "A place to practise Git",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/icyflame/git-sandbox.git"
},
"author": "Siddharth Kannan <[email protected]> (http://icyflame.github.io)",
"license": "ISC",
"bugs": {
"url": "https://github.com/icyflame/git-sandbox/issues"
},
"homepage": "https://github.com/icyflame/git-sandbox#readme",
"repository": "https://github.com/AGV-IIT-KGP/git-sandbox",
"homepage": "https://github.com/AGV-IIT-KGP/git-sandbox#readme",
"dependencies": {
"rev-hash": "^1.0.0"
}
}
100 changes: 46 additions & 54 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,64 @@
var fs = require('fs');
var crypto = require('crypto');

function revArray(inputArr) {
var output = [];
for(i in inputArr) {
output.push(revHash(inputArr[i]));
}
return output;
}

var filename = 'README.md';
var entryRegex = /\*\s[a-zA-Z\s]*\s\[.*\]\(.*\)/g;

// read the file from the filesystem
fs.readFile(filename, function(err, data) {
if(err) {
console.error(err);
process.exit(1);
} else {
// isolate the part of the file that we want
// to analyse
var fileData = data.toString();
fs.readFile(filename, function (err, data) {
if (err) {
console.error(err);
process.exit(1);
} else {
// isolate the part of the file that we want
// to analyse
var fileData = data.toString();

var startString = "<!--ALPHA-->";
var endString = "<!--ALPHAEND-->";
var startIndex = fileData.search(startString) + startString.length;
var endIndex = fileData.search(endString);
var startString = '<!--ALPHA-->';
var endString = '<!--ALPHAEND-->';
var startIndex = fileData.search(startString) + startString.length;
var endIndex = fileData.search(endString);

var reqSubstr = fileData.substr(startIndex, endIndex);
var reqSubstr = fileData.substr(startIndex, endIndex);

// make sure that start and end strings are not
// a part of the extracted string
reqSubstr = reqSubstr.replace(startString, '').replace(endString, '');
// make sure that start and end strings are not
// a part of the extracted string
reqSubstr = reqSubstr.replace(startString, '').replace(endString, '');

// split using a newline to get the list of entries
var lines = reqSubstr.split('\n');
// split using a newline to get the list of entries
var lines = reqSubstr.split('\n');

// remove all the empty string occurences from the list
while((remIndex = lines.indexOf('')) != -1) {
lines.splice(remIndex, 1);
}
// remove all the empty string occurences from the list
while((remIndex = lines.indexOf('')) != -1) {
lines.splice(remIndex, 1);
}

// check if all entries match regex
var checkFormat = lines.slice();
// check if all entries match regex
var checkFormat = lines.slice();

for(i in checkFormat) {
if(!checkFormat[i].match(entryRegex)){
console.log("One of the entries does not match the format!");
console.log("Fix this entry: ");
console.log("--------------------");
console.log(checkFormat[i]);
process.exit(1);
}
}
for (i in checkFormat) {
if (!checkFormat[i].match(entryRegex)) {
console.log('One of the entries does not match the format!');
console.log('Fix this entry: ');
console.log('--------------------');
console.log(checkFormat[i]);
process.exit(1);
}
}

// make a copy of the list that we will sort
var copy = lines.slice();
copy.sort();
// make a copy of the list that we will sort
var copy = lines.slice();
copy.sort();

// calculate the SHA256 hash of the string versions
// of the two lists
orgHash = crypto.createHash('sha256').update(lines.toString(), 'utf8').digest('hex');
sortedHash = crypto.createHash('sha256').update(copy.toString(), 'utf8').digest('hex');
// calculate the SHA256 hash of the string versions
// of the two lists
orgHash = crypto.createHash('sha256').update(lines.toString(), 'utf8').digest('hex');
sortedHash = crypto.createHash('sha256').update(copy.toString(), 'utf8').digest('hex');

if(orgHash !== sortedHash) {
process.exit(1);
} else {
process.exit();
}
}
if (orgHash !== sortedHash) {
process.exit(1);
} else {
process.exit();
}
}
});

0 comments on commit 02f93ad

Please sign in to comment.