Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config file not working #48

Closed
pedro93 opened this issue Jan 31, 2017 · 3 comments
Closed

Config file not working #48

pedro93 opened this issue Jan 31, 2017 · 3 comments
Labels

Comments

@pedro93
Copy link
Collaborator

pedro93 commented Jan 31, 2017

I am trying to create a configuration file to use with pwmetrics however it is not being used by the library. I have a file performance-test.config.js that looks like this:

module.exports = {
    runs: 5,
    flags: {
        expectations: true,
    },
    sheets: {
        // sheets configuration
    },
    expectations: {
        ttfmp: {
            warn: '>=3000',
            error: '>=5000',
        },
        tti: {
            warn: '>=5000',
            error: '>=15000',
        },
        ttfcp: {
            warn: '>=1500',
            error: '>=3000',
        },
        psi: {
            warn: '>=3000',
            error: '>=6000',
        },
    },
};

I'm executing pwmetrics like this:

function runPerf(url, cb){
    const pwmetrics = path.join(__dirname, '../node_modules/pwmetrics/bin/cli.js');
    const perfConfig = require('../config/performance-test.config.js');
    const child = cp.exec('node ' + pwmetrics + ' ' + url + ' --config=' + perfConfig);
    child.stderr.pipe(process.stderr);
    child.stdout.pipe(process.stdout);
    child.on('close', (code) => {
        cb(code);
    });
}

I think the issue is with how the cli reads the options from the command line. Is there an option to override every command line option with the data from a json?

@denar90
Copy link
Collaborator

denar90 commented Jan 31, 2017

Do you use latest version (1.2.4) or master? API you wanna use is in master branch and it hasn't been release yet.


Tips:

E.g.
my_module.js

const PWmetrics = require('pwmetrics');
const perfConfig = require('path-to-my-config/config.js');
....
function runPerf(url, cb){
  const pwmetrics = new PWmetrics(url, pwmetricsConfig);
  pwmetrics.start().then(cd);
}

perfConfig.js

module.exports = {
    //flags - the place where cli options can be put
    flags: {
        expectations: true,
        runs: 5
    },
    sheets: {
        // sheets configuration
    },
    expectations: {
        ttfmp: {
            warn: '>=3000',
            error: '>=5000',
        },
        tti: {
            warn: '>=5000',
            error: '>=15000',
        },
        ttfcp: {
            warn: '>=1500',
            error: '>=3000',
        },
        psi: {
            warn: '>=3000',
            error: '>=6000',
        },
    },
};

@pedro93
Copy link
Collaborator Author

pedro93 commented Jan 31, 2017

Thank you for the reply!

I am running the latest version from npm (1.2.4)

I will try it out tomorrow and report back but my use case requires that I use the cli version because I want to create a child process for running pwmetrics (in essence I want to deploy an express server and run pwmetrics on it, all in one go).

If this is not possible with the cli, I'll try the library and create an external script which I'll call from my cp.exec call though I don't find that a good solution either...

Appreciate the help @denar90 :)

@denar90
Copy link
Collaborator

denar90 commented Feb 26, 2017

@pedro93 feel free to reopen it.

@denar90 denar90 closed this as completed Feb 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants