Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

Commit

Permalink
Add eslint to project.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed May 15, 2019
1 parent b397339 commit 3f155be
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
env: {
node: true
},
extends: [
'eslint-config-digitalbazaar'
]
};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Commands:
```
All tests will run against your binary and assume that an exit code greater than 0 represents an error.

### Creating a config file
### Creating a Config File
An example local configuration for the test suite. To use:

1. Copy the file config.json.example to a new file called config.json.
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"devDependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"eslint": "^5.16.0",
"eslint-config-digitalbazaar": "^2.0.0",
"mocha": "^5.2.0"
},
"scripts": {
Expand Down
34 changes: 34 additions & 0 deletions test/v1/input/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';
const path = require('path');
const util = require('util');

const exec = util.promisify(require('child_process').exec);

async function generate(file, options) {
options = options || {};
const filePath = path.join(__dirname, 'input', `${file}.httpMessage`);
const date = options.date || new Date().toGMTString();
const latestDate = `date: ${date}`;
let args = '';
for(const key in options.args) {
let value = options.args[key];
if(Array.isArray(value)) {
value = `--${key} "${value.join(' ')}" `;
} else {
value = `--${key} ${value} `;
}
args += value;
}
// this cat filePath - the dash is the last pipe op
const httpMessage = `echo ${latestDate} | cat ${filePath} - | `;
const generate = `${options.generator} ${options.command} `;
const {stdout, stderr} = await exec(httpMessage + generate + args);
if(stderr) {
throw new Error(stderr);
}
return stdout;
}

module.exports = {
generate
};

0 comments on commit 3f155be

Please sign in to comment.