Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #16 from Financial-Times/get-session-id
Browse files Browse the repository at this point in the history
Get sessionId from test_settings in globals
  • Loading branch information
ironsidevsquincy authored Sep 21, 2016
2 parents 3088127 + 8049e06 commit 3536e62
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
"name": "@financial-times/n-automation",
"main": "build/main.js",
"dependencies": {
"fs": "0.0.2"
"@financial-times/n-logger": "^5.4.0",
"isomorphic-fetch": "^2.2.1",
"nodemailer": "^2.6.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Financial-Times/n-automation.git"
},
"license": "MIT",
"devDependencies": {
"npm-prepublish": "^1.2.1",
"babel-cli": "^6.5.1",
"babel-plugin-transform-object-assign": "^6.5.0",
"babel-preset-es2015": "^6.5.0",
"babel-register": "^6.5.1",
"chai": "^3.5.0",
"denodeify": "^1.2.1",
"eslint": "^2.9.0",
"lintspaces-cli": "^0.1.1",
"mocha": "^2.2.1",
"npm-prepublish": "^1.2.1",
"sinon": "^1.17.4"
},
"engines": {
Expand Down
13 changes: 10 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ const sendSlackNotification = require('./slack');
const logger = require('@financial-times/n-logger').default.logger;

function emptyReportsFolder (path) {
logger.info('Deleting old reports...')

const reportNames = fs.readdirSync(path);
logger.info('Deleting old reports...');

let reportNames;
try {
reportNames = fs.readdirSync(path);
} catch (err) {
if (err.code === 'ENOENT') {
return;
}
}

logger.info(reportNames);

Expand Down
22 changes: 12 additions & 10 deletions src/reporter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const fs = require('fs')
const denodeify = require('denodeify');

const writeFile = denodeify(require('fs').writeFile);

function safePath (path) {
const lastSlash = path.lastIndexOf('/');
Expand All @@ -20,15 +22,15 @@ module.exports = {
const outputFolder = safePath(options.output_folder);
const prefix = options.filename_prefix;
const modules = results.modules;
results.sessionId = options.globals.sessionId;


for (const moduleName in modules) {
if (modules.hasOwnProperty(moduleName)) {
results.sessionId = options.globals.test_settings.sessionId;
const writes = Object.keys(modules)
.map(moduleName => {
const file = `${outputFolder}${prefix}${moduleName.replace('/', '-')}.json`;
fs.writeFile(file, JSON.stringify(results, null, 4))
}
}
done();
return writeFile(file, JSON.stringify(results, null, 4))
.catch(() => { });
});

Promise.all(writes)
.then(() => { done() });
}
};

0 comments on commit 3536e62

Please sign in to comment.