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

[v1] Document this.sao.opts for passing variables to sao context #124

Open
shaunwarman opened this issue Mar 5, 2019 · 2 comments
Open

Comments

@shaunwarman
Copy link

I probably missed it. But it doesn't seem obvious how to pass in variables to sao context.

My CLI tool uses cac for something like

cli create <applicationName>

And need to feed this value into sao context

await sao({ applicationName, generator, ...etc })

It seems it's available on this.sao.opts is this documented? If not, I'll send a PR.

@shaunwarman shaunwarman changed the title Document this.sao.opts for passing variables to sao context [v1] Document this.sao.opts for passing variables to sao context Mar 5, 2019
@lirantal
Copy link
Contributor

lirantal commented Mar 5, 2019

Is this an example of what you were looking for: https://github.com/lirantal/create-node-lib/blob/master/bin/cli.js ?

@shaunwarman
Copy link
Author

Ah more so something that shows you can pass variables to soa generator and get access to those variables in the soa context.

Example

await sao({
      applicationName,
      generator,
      outDir: targetPath,
      npmClient: 'npm'
    }).run();

saofile.js

const questions = require('./src/utils/prompts');

module.exports = {
  prompts() {
    const { applicationName } = this.sao.opts; // <- this isn't documented
    return questions.configure(applicationName);
  },
  actions: [
   ...
  ],
  async completed() {
    this.gitInit();
    await this.npmInstall();
    this.showProjectTips();
  }
};

So if I'm looking at v1 documentation on sao generator instance it's not immediately obvious that you can pass variables in and have access to those on this.sao.opts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants