mirror of
https://github.com/wassname/generator-react-webpack.git
synced 2026-09-09 11:22:44 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47f1273828 | ||
|
|
56ff5c6281 | ||
|
|
7269a0a315 | ||
|
|
6a3da576fa | ||
|
|
e7bbcb1fe7 | ||
|
|
8a2fc142ba | ||
|
|
76f0e8e672 |
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- '0.10'
|
- '4.1.0'
|
||||||
before_install:
|
before_install:
|
||||||
- currentfolder=${PWD##*/}
|
- currentfolder=${PWD##*/}
|
||||||
- if [ "$currentfolder" != 'generator-react-webpack' ]; then cd .. && eval "mv $currentfolder generator-react-webpack" && cd generator-react-webpack; fi
|
- if [ "$currentfolder" != 'generator-react-webpack' ]; then cd .. && eval "mv $currentfolder generator-react-webpack" && cd generator-react-webpack; fi
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ let path = require('path');
|
|||||||
let fs = require('fs');
|
let fs = require('fs');
|
||||||
|
|
||||||
// Set the base root directory for our files
|
// Set the base root directory for our files
|
||||||
let baseRootPath = path.join(__dirname, '../../node_modules/react-webpack-template');
|
let baseRootPath = path.dirname(require.resolve('react-webpack-template'));
|
||||||
|
|
||||||
module.exports = generator.Base.extend({
|
module.exports = generator.Base.extend({
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "generator-react-webpack",
|
"name": "generator-react-webpack",
|
||||||
"version": "2.0.1",
|
"version": "2.1.0",
|
||||||
"description": "Yeoman generator for ReactJS and Webpack",
|
"description": "Yeoman generator for ReactJS and Webpack",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"yeoman-generator",
|
"yeoman-generator",
|
||||||
|
|||||||
@@ -94,4 +94,19 @@ describe('Utilities:Yeoman', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getDestinationPath', () => {
|
||||||
|
|
||||||
|
it('should return the correct filesystem path for all components', () => {
|
||||||
|
|
||||||
|
expect(utils.getDestinationPath('test', 'action', 'Actions')).to.equal('src/actions/TestActions.js');
|
||||||
|
expect(utils.getDestinationPath('subfolder/test', 'action', 'Actions')).to.equal('src/actions/subfolder/TestActions.js');
|
||||||
|
|
||||||
|
expect(utils.getDestinationPath('test', 'source', 'Source')).to.equal('src/sources/TestSource.js');
|
||||||
|
expect(utils.getDestinationPath('subfolder/test', 'source', 'Source')).to.equal('src/sources/subfolder/TestSource.js');
|
||||||
|
|
||||||
|
expect(utils.getDestinationPath('test', 'store', 'Store')).to.equal('src/stores/TestStore.js');
|
||||||
|
expect(utils.getDestinationPath('subfolder/test', 'store', 'Store')).to.equal('src/stores/subfolder/TestStore.js');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
+28
-1
@@ -113,10 +113,37 @@ let getAppName = (appName) => {
|
|||||||
return _.camelize(_.slugify(_.humanize(appName)));
|
return _.camelize(_.slugify(_.humanize(appName)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the wanted destination path
|
||||||
|
* @param {String} name Name of the file
|
||||||
|
* @param {String} type The type to use (e.g. action, store, ...)
|
||||||
|
* @param {Suffix} suffix The suffix to use for the file (e.g. Store, Actions, ...)
|
||||||
|
* @return {String} Final path
|
||||||
|
*/
|
||||||
|
let getDestinationPath = (name, type, suffix) => {
|
||||||
|
|
||||||
|
let cleanedPaths = getCleanedPathName(name, suffix);
|
||||||
|
let fsParts = cleanedPaths.split('/');
|
||||||
|
let actionBaseName = _.capitalize(fsParts.pop());
|
||||||
|
let partPath = fsParts.join('/');
|
||||||
|
|
||||||
|
let fsPath = configUtils.getChoiceByKey('path', type).path;
|
||||||
|
|
||||||
|
let parts = [ fsPath ];
|
||||||
|
if(partPath.length > 0) {
|
||||||
|
parts.push(partPath);
|
||||||
|
}
|
||||||
|
parts.push(actionBaseName);
|
||||||
|
let fullPath = parts.join('/');
|
||||||
|
|
||||||
|
return `${fullPath}.js`;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getBaseDir: getBaseDir,
|
getBaseDir: getBaseDir,
|
||||||
getAllSettingsFromComponentName: getAllSettingsFromComponentName,
|
getAllSettingsFromComponentName: getAllSettingsFromComponentName,
|
||||||
getAppName: getAppName,
|
getAppName: getAppName,
|
||||||
getCleanedPathName: getCleanedPathName,
|
getCleanedPathName: getCleanedPathName,
|
||||||
getComponentStyleName: getComponentStyleName
|
getComponentStyleName: getComponentStyleName,
|
||||||
|
getDestinationPath: getDestinationPath
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user