forked from angular-fullstack/generator-angular-fullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request angular-fullstack#1241 from kingcody/refactor/unif…
…y-script-base refactor(gen): improve `generator-base` and `util` wiring
- Loading branch information
Showing
5 changed files
with
70 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
|
||
import util from 'util'; | ||
import path from 'path'; | ||
import * as genUtils from './util'; | ||
|
||
export function genBase(self) { | ||
self = self || this; | ||
|
||
try { | ||
self.appname = require(path.join(process.cwd(), 'bower.json')).name; | ||
} catch (e) { | ||
self.appname = self.name || path.basename(process.cwd()); | ||
} | ||
self.appname = self._.camelize(self._.slugify(self._.humanize(self.appname))); | ||
self.scriptAppName = self.appname + genUtils.appSuffix(self); | ||
|
||
self.filters = self.filters || self.config.get('filters'); | ||
|
||
// dynamic assertion statements | ||
self.expect = function() { | ||
return self.filters.expect ? 'expect(' : ''; | ||
}; | ||
self.to = function() { | ||
return self.filters.expect ? ').to' : '.should'; | ||
}; | ||
|
||
// dynamic relative require path | ||
self.relativeRequire = genUtils.relativeRequire.bind(self); | ||
// process template directory | ||
self.processDirectory = genUtils.processDirectory.bind(self); | ||
// rewrite a file in place | ||
self.rewriteFile = genUtils.rewriteFile; | ||
} | ||
|
||
export function genNamedBase(self) { | ||
self = self || this; | ||
|
||
// extend genBase | ||
genBase(self); | ||
|
||
var name = self.name.replace(/\//g, '-'); | ||
|
||
self.cameledName = self._.camelize(name); | ||
self.classedName = self._.classify(name); | ||
|
||
self.basename = path.basename(self.name); | ||
self.dirname = (self.name.indexOf('/') >= 0) ? path.dirname(self.name) : self.name; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters