Skip to content

Commit

Permalink
Rewrite the tests, add 'files' field to the 'package.json', flatten f…
Browse files Browse the repository at this point in the history
…iles structure.
  • Loading branch information
alexpods committed Apr 12, 2015
1 parent ccfe9cb commit adfaaf8
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 88 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Node.js folders
*coverage/
*node_modules/

# Build artefacts
*build/
node_modules

# OS generated files and folders
.DS_Store
Expand Down
17 changes: 0 additions & 17 deletions Gruntfile.js

This file was deleted.

11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ is-iojs determines if runtime is io.js.

## Quick start

First you need to integrate is-iojs into your application.
First you need to integrate is-iojs into your application:

```javascript
var isIojs = require('is-iojs');
Expand All @@ -24,11 +24,14 @@ if (isIojs) {
}
```

## Running the build
## Running the tests

This module can be built using [Grunt](http://gruntjs.com/). Besides running the tests, this also analyses the code. To run Grunt, go to the folder where you have installed is-iojs and run `grunt`. You need to have [grunt-cli](https://github.com/gruntjs/grunt-cli) installed.
Just clone this repository, install its dependencies and run `npm test` command:

$ grunt
$ git clone https://github.com/alexpods/is-iojs
$ cd is-iojs
$ npm install
$ npm test

## License

Expand Down
7 changes: 4 additions & 3 deletions lib/isIojs.js → index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var cp = require('child_process');
var execSync = require('child_process').execSync;

module.exports = (function () {
if (!cp.execSync) {
if (!execSync) {
return false;
}
/**
Expand All @@ -12,5 +12,6 @@ module.exports = (function () {
if (~[ 'v1.0.0', 'v1.0.1' ].indexOf(process.version)) {
return true;
}
return /iojs\.org/.test(cp.execSync('"' + process.execPath + '" -h', { encoding: 'ascii' }));

return /iojs\.org/.test(execSync('"' + process.execPath + '" -h', { encoding: 'ascii' }));
})();
36 changes: 21 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
{
"name": "is-iojs",
"version": "1.0.1",
"version": "1.1.0",
"description": "is-iojs determines if runtime is io.js.",
"contributors": [
{
"name": "Aleksey Podskrebyshev",
"email": "[email protected]"
},
{
"name": "Golo Roden",
"email": "[email protected]"
}
"main": "index.js",
"scripts": {
"test": "mocha test"
},
"files": [
"index.js"
],
"main": "lib/isIojs.js",
"devDependencies": {
"assertthat": "0.4.2",
"grunt": "0.4.5",
"proxyquire": "1.3.1",
"tourism": "0.13.2"
"chai": "^2.2.0",
"mocha": "^2.2.4",
"proxyquire": "1.3.1"
},
"repository": {
"type": "git",
"url": "git://github.com/alexpods/is-iojs.git"
},
"keywords": [
"iojs",
"io.js",
"runtime",
"check"
],
"contributors": [
{
"name": "Aleksey Podskrebyshev",
"email": "[email protected]"
},
{
"name": "Golo Roden",
"email": "[email protected]"
}
],
"license": "MIT"
}
34 changes: 34 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var expect = require('chai').expect;
var proxyquire = require('proxyquire');

// TODO: Add more reliable tests. Maybe based on [dnt package](https://www.npmjs.com/package/dnt)

describe('is-iojs', function() {

it('should be a boolean value', function() {
var isIojs = require('./index');
expect(isIojs).to.be.a('boolean');
});

it('should equal true if runtime is io.js', function() {
var isIojs = proxyquire('./index', {
child_process: {
execSync: function() {
return 'some description containing iojs.org substring';
}
}
});
expect(isIojs).to.equal(true);
});

it('should equal false if runtime is not io.js', function() {
var isIojs = proxyquire('./index', {
child_process: {
execSync: function() {
return 'some text not containing iojs.org substring'.replace('iojs.org','');
}
}
});
expect(isIojs).to.equal(false);
});
});
44 changes: 0 additions & 44 deletions test/isIojsTests.js

This file was deleted.

0 comments on commit adfaaf8

Please sign in to comment.