Skip to content

Commit

Permalink
fix generator
Browse files Browse the repository at this point in the history
- update test path from `spec` to `test`
- update template, make use of `prop-types` rather than React.PropTypes
- use `mkdirp` package in generator
  • Loading branch information
mz026 committed May 28, 2017
1 parent b362a13 commit 54c5c77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 6 additions & 5 deletions bin/_generate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { execSync } from 'child_process'
import path from 'path'
import os from 'os'
import mkdirp from 'mkdirp'

let srcRoot = path.join(__dirname, '..', 'app')
let { type, componentName, pathPrefix } = extractArgs()

mkdirp({ type, pathPrefix });
makeDirectory({ type, pathPrefix });
copyFiles({ type, pathPrefix, componentName });
sed({ type, pathPrefix, componentName });
console.log(`created file: ${codePath({ type, pathPrefix, componentName })}`);
Expand All @@ -26,10 +27,10 @@ function templateFilePath ({ type }) {
return path.join(__dirname, `${type}.template.js`)
}

function mkdirp ({ type, pathPrefix }) {
function makeDirectory ({ type, pathPrefix }) {
console.log('mkdir...');
execSync(`mkdir -p ${codeDir({ type, pathPrefix })}`)
execSync(`mkdir -p ${testDir({ type, pathPrefix })}`)
mkdirp.sync(codeDir({ type, pathPrefix }))
mkdirp.sync(testDir({ type, pathPrefix }))
}
function copyFiles ({ type, pathPrefix, componentName }) {
console.log('copy files...');
Expand All @@ -41,7 +42,7 @@ function codeDir ({ type, pathPrefix }) {
return path.join(srcRoot, `${type}s`, pathPrefix)
}
function testDir ({ type, pathPrefix }) {
return path.join(srcRoot, 'spec', `${type}s`, pathPrefix)
return path.join(srcRoot, 'test', `${type}s`, pathPrefix)
}

function codePath ({ type, pathPrefix, componentName }) {
Expand Down
3 changes: 2 additions & 1 deletion bin/component.template.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react'
import React, { Component } from 'react'
import PropTypes from 'prop-types'

class COMPONENT_NAME extends Component {
render() {
Expand Down
3 changes: 2 additions & 1 deletion bin/container.template.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component, PropTypes } from 'react'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'

class COMPONENT_NAME extends Component {
render() {
Expand Down

0 comments on commit 54c5c77

Please sign in to comment.