Skip to content

Commit 9edea8d

Browse files
committed
Matter specific files are now copied when yes is answered in prompt. Prompt answers moved to this.answers from this.props (within generator context).
1 parent a4c5af1 commit 9edea8d

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

generators/app/index.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ module.exports = yeoman.generators.Base.extend({
2222

2323
var prompts = [{
2424
type: 'confirm',
25-
name: 'someOption',
25+
name: 'includeMatter',
2626
message: 'Would you like to include Matter.js for authentication?',
2727
default: false
2828
}];
2929

3030
this.prompt(prompts, function (props) {
31-
this.props = props;
32-
// To access props later use this.props.someOption;
31+
this.answers = props;
32+
// To access prompt answers later use this.answers.someOption;
3333
done();
3434
}.bind(this));
3535
},
@@ -40,9 +40,16 @@ module.exports = yeoman.generators.Base.extend({
4040
{src:'app/**', dest: 'app'},
4141
{src:'assets/**', dest: 'assets'},
4242
{src:'bin/**', dest: 'bin'},
43-
{src:'lib/**', dest: 'lib'},
43+
{src:'lib/**', dest: 'lib'}
4444
];
4545
this.copyFiles(appFilesArray);
46+
//Add matter specific files
47+
if(this.answers.includeMatter){
48+
this.copyFiles([
49+
{src: '_matter-helper.js', dest: 'app/helpers/matter.js'},
50+
{src: '_profile-action.js', dest: 'app/actions/profile.js'}
51+
]);
52+
}
4653
},
4754
projectfiles: function () {
4855
var projectFilesArray = [
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/** Matter Singleton
2+
*/
3+
4+
import {merge} from 'lodash';
5+
import Matter from 'kyper-matter';
6+
7+
//Default configuration options
8+
let defaultOptions = {
9+
};
10+
11+
let instance = null;
12+
class MatterInstance {
13+
constructor(appName, options) {
14+
if (!instance) {
15+
instance = new Matter(appName, options);
16+
}
17+
return instance;
18+
}
19+
}
20+
21+
//Create singleton instance of Matter using project name
22+
let matter = new MatterInstance('<% name %>', defaultOptions);
23+
24+
export default matter;

0 commit comments

Comments
 (0)