fix: fixed command generator
RENAME
src/generators/app/index.ts
src/generators/app.ts
@@ -9,7 +9,7 @@ import yosay = require('yosay')
const sortPjson = require('sort-pjson')
const fixpack = require('fixpack')
const debug = require('debug')('generator-anycli')
-const {version} = require('../../../package.json')
+const {version} = require('../../package.json')
function stringToArray(s: string) {
const keywords: string[] = []
@@ -230,7 +230,7 @@ class App extends Generator {
}
writing() {
- this.sourceRoot(path.join(__dirname, '../../../templates'))
+ this.sourceRoot(path.join(__dirname, '../../templates'))
switch (this.type) {
case 'multi':

RENAME
src/generators/command/index.ts
src/generators/command.ts
@@ -6,9 +6,9 @@ import * as path from 'path'
import * as Generator from 'yeoman-generator'
import yosay = require('yosay')
-import {Options} from '../../commands/command'
+import {Options} from '../commands/command'
-const {version} = require('../../../package.json')
+const {version} = require('../../package.json')
class CommandGenerator extends Generator {
pjson!: any
@@ -24,16 +24,17 @@ class CommandGenerator extends Generator {
async prompting() {
this.pjson = this.fs.readJSON('package.json')
+ this.pjson.anycli = this.pjson.anycli || {}
if (!this.pjson) throw new Error('not in a project directory')
this.log(yosay(`Adding a command to ${this.pjson.name} Version: ${version}`))
}
writing() {
- this.sourceRoot(path.join(__dirname, '../../../templates'))
+ this.sourceRoot(path.join(__dirname, '../../templates'))
let bin = this.pjson.anycli.bin || this.pjson.anycli.dirname || this.pjson.name
if (bin.includes('/')) bin = bin.split('/').pop()
const cmd = `${bin} ${this.options.name}`
- const opts = {...this.options, cmd, _}
+ const opts = {...this.options, bin, cmd, _}
this.fs.copyTpl(this.templatePath(`command.${this._ext}.ejs`), this.destinationPath(`src/commands/${this._path}.${this._ext}`), opts)
// this.fs.copyTpl(this.templatePath(`plugin/src/hooks/init.${this._ext}`), this.destinationPath(`src/hooks/init.${this._ext}`), this)
if (this._mocha) {

fix: fixed command generator