установка зависимостей не работает в yeoman - PullRequest
0 голосов
/ 17 июня 2020
• 1000 yo my-custom-generator

index. js

'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');

module.exports = class extends Generator {
  prompting() {
    // Have Yeoman greet the user.
    this.log(
      yosay(
        `Welcome to the epic ${chalk.red(
          "generator-cvsdigital-sdk-nodeapp-generator"
        )} generator!`
      )
    );
    const prompts = [
      {
        type: "input",
        name: "appName",
        message: "Your project name",
        // Defaults to the project's folder name if the input is skipped
        default: "app"
      }
    ];

    return this.prompt(prompts).then(props => {
      // To access props later use this.props.someAnswer;
      this.props = props;
      this._setDefaultValues();
    });
  }

  _setDefaultValues() {
    this.props.appName = this.props.appName || "app";
  }

  writing() {
    const appName = this.props.appName;
    // This.fs.copyTpl(
    //   this.templatePath("package.json"),
    //   this.destinationPath(`${appName}/${"package.json"}`)
    // );
    this.fs.copy(this.templatePath(), this.destinationPath(`${appName}`));
    this.runInstall();
  }

  runInstall() {
    const npmdir = process.cwd() + "/" + this.appname;
    console.log("director", npmdir);
    this.installDependencies({
      npm: true,
      bower: false
    });
  }
};
...