Skip to content

Commit

Permalink
Updated tests, fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
automation-stack committed Jul 12, 2016
1 parent 9d69e31 commit 3c29492
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -137,4 +137,4 @@
- "flowtype"
settings:
flowtype:
onlyFilesWithFlowAnnotation: false
onlyFilesWithFlowAnnotation: true
7 changes: 2 additions & 5 deletions index.js
Expand Up @@ -34,12 +34,12 @@ function expose(result: string): string {
}
}

function machineIdSync(original: boolean): string {
export function machineIdSync(original: boolean): string {
let id: string = expose(execSync(guid[platform]).toString());
return original ? id : hash(id);
}

function machineId(original: boolean): Promise {
export function machineId(original: boolean): Promise {
return new Promise((resolve: Function, reject: Function): Object => {
return exec(guid[platform], (err: any, stdout: any, stderr: any): string => {
if (err) {
Expand All @@ -50,6 +50,3 @@ function machineId(original: boolean): Promise {
});
});
}


export {machineId, machineIdSync};
5 changes: 3 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "electron-machine-id",
"version": "1.0.0",
"main": "dist/index.js",
"main": "./dist/index.js",
"description": "Unique cross-platform machine id for Electron application (no admin provoleges required).",
"readme": "README.md",
"author": "Aleksandr Komlev",
Expand All @@ -26,7 +26,8 @@
},
"homepage": "https://github.com/automation-stack/electron-machine-id#readme",
"scripts": {
"build": "WEBPACK=node_modules/webpack/bin/webpack.js && NODE_ENV=production && $WEBPACK --config webpack.config.babel.js",
"build": "WEBPACK=node_modules/webpack/bin/webpack.js && $WEBPACK --config webpack.config.babel.js",
"prepublish": "npm run build && npm run test",
"lint": "node_modules/eslint/bin/eslint.js -c .eslintrc ./src",
"test": "node_modules/mocha/bin/mocha --compilers js:babel-core/register ./tests"
},
Expand Down
12 changes: 10 additions & 2 deletions tests/index.js
@@ -1,6 +1,6 @@
import {assert} from 'chai';
import {machineId, machineIdSync} from '../index';

import {machineId, machineIdSync} from '../dist/index';
console.log(machineId, machineIdSync);

let {platform} = process,
originalPattern = {
Expand Down Expand Up @@ -35,3 +35,11 @@ describe('Sync call: machineIdSync()', function() {
assert.match(machineIdSync(), hashPattern);
});
});

describe('CommonJS imports', function () {
it('should return function machineIdSync, machineId', function () {
let __module__ = require('../dist/index');
assert.isFunction(__module__.machineId);
assert.isFunction(__module__.machineIdSync);
});
});
8 changes: 6 additions & 2 deletions webpack.config.babel.js
Expand Up @@ -13,10 +13,12 @@ export default {
entry: ['./index.js'],
output: {
path: './dist',
filename: 'index.js'
filename: 'index.js',
library: 'electron-machine-id',
libraryTarget: 'umd'
},
debug: false,
target: 'electron',
debug: false,
module: {
loaders: [
{
Expand All @@ -41,8 +43,10 @@ export default {
//http://webpack.github.io/docs/configuration.html#node
console: false,
process: false,
child_process: false,
global: false,
buffer: false,
crypto: false,
__filename: false,
__dirname: false
},
Expand Down

0 comments on commit 3c29492

Please sign in to comment.