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

How to call a generator from another generator #356

Open
AboyL opened this issue Sep 15, 2022 · 0 comments
Open

How to call a generator from another generator #356

AboyL opened this issue Sep 15, 2022 · 0 comments

Comments

@AboyL
Copy link

AboyL commented Sep 15, 2022

I want to do a function to upgrade one project, for this I need to create a temporary project first, and then move the content of this project from the temporary folder to the project folder, so I need to create a custom generator call other generators, or call a method to process the template, is there a corresponding way?

like


  import { execSync } from 'child_process';
  import chalk from 'chalk';
  
  import path from 'path';
  import { ActionType, CustomActionFunction, NodePlopAPI } from 'plop';
  import { getPackageVersions } from '../utils';
  
  export default function (plop: NodePlopAPI) {
  
      plop.setActionType('migration', async function (answers, config, plop) {
          const v = execSync('git status').toString()
          if (!v.includes('working tree clean')) {
              process.exit()
          }
  
          // call ohter generator
  
          return 'success status message';
      });
  
      plop.setGenerator('migration', {
          description: 'migration',
          prompts: [],
          actions: [{
              type: 'migration'
          }]
      });
  }

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

No branches or pull requests

1 participant