Skip to content

Commit

Permalink
feat(taro-cli): creator 的 sourceRoot 可以从外部传入
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Jul 10, 2019
1 parent c806c58 commit ceab89d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/taro-cli/src/create/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export default class Creator {
protected _rootPath: string
private _destinationRoot: string

constructor () {
constructor (sourceRoot?: string) {
const store = memFs.create()
this.fs = editor.create(store)
this.sourceRoot(path.join(getRootPath()))
this.sourceRoot(sourceRoot || path.join(getRootPath()))
this.init()
}

Expand All @@ -65,6 +65,7 @@ export default class Creator {
if (!fs.existsSync(this._rootPath)) {
fs.ensureDirSync(this._rootPath)
}
console.log('this._rootPath: ', this._rootPath)
return this._rootPath
}

Expand Down
5 changes: 3 additions & 2 deletions packages/taro-cli/src/create/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export interface IProjectConf {
typescript?: boolean,
css: 'none' | 'sass' | 'stylus' | 'less',
date?: string,
src?: string
src?: string,
sourceRoot?: string
}

interface AskMethods {
Expand All @@ -34,7 +35,7 @@ export default class Project extends Creator {
public conf: IProjectConf

constructor (options: IProjectConf) {
super()
super(options.sourceRoot)
const unSupportedVer = semver.lt(process.version, 'v7.6.0')
if (unSupportedVer) {
throw new Error('Node.js 版本过低,推荐升级 Node.js 至 v8.0.0+')
Expand Down

0 comments on commit ceab89d

Please sign in to comment.