Skip to content

Conversation

iMuzz
Copy link
Contributor

@iMuzz iMuzz commented Jan 10, 2018

No description provided.

'X-Build-Meta-OS': `${os.type().toLowerCase()}@${os.release()}`,
};

if (data['x-build-outputs'] !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing it through data['x-build-outputs'], why not just pass it as a param into invoke?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I thought about that..

But the last parameter is optional..

I could make it so invoke takes another param. But then I'd have to change this line to be:

return invoke(scope.key, scope.service, action, data, undefined, outputs).then((response) => {

Long story short:

  1. I didn't want to add a parameter and then have to pass in undefined there.
  2. I didn't want to change the order of the parameters coming in.

But if we really don't like this.. I'm happy to change it so that we pass in this object so that there isn't an order dependency anymore!

{ 
  key: '',
  service: '',
  action: '' ,
  data: '',
  isCLI : ''
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about doing this:

invoke(key, service, action, data, opts)

And making ops have isCLI, outputs and whatever else we decide to add in the future?

I'm also not against just making it an object.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quite like just making it an object.

src/api.js Outdated
const linksPath = path.join(utils.sharedDirectoryPath(), 'links.json');

module.exports.run = (action, d, cb) => {
module.exports.run = (action, d, outputs, cb) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt this mean that if you want to use run with a cb that you have to pass in something for outputs?

const api = require('api').config('domh_ccd5142d2107c48ce32f75');

api('build-test')
  .run('helloWorld', { name: 'Name' }, 
   // this has to be here now? 
   {},
   function cb () {})

Can you make it optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (data['x-build-outputs'] !== undefined) {
const parsedOutput = querystring.stringify(data['x-build-outputs']);
delete data['x-build-outputs'];
headers['X-Build-Output'] = parsedOutput;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test here to make sure the header gets set? https://github.com/readmeio/api/blob/master/test/commands/run.test.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@domharrington is this file for the .run function?

@mjcuva mjcuva merged commit 617aa52 into master Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants