Skip to content

Instantly share code, notes, and snippets.

View alieslamifard's full-sized avatar
🏠
Working from home

Ali Eslamifard alieslamifard

🏠
Working from home
  • Homeday
View GitHub Profile
@alieslamifard
alieslamifard / yeoman-7.js
Created March 5, 2019 14:29
yeoman generator
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
module.exports = class extends Generator {
// Note: arguments and options should be defined in the constructor.
constructor(args, opts) {
super(args, opts);
@alieslamifard
alieslamifard / yeoman-6.js
Created March 5, 2019 14:28
yeoman generator
constructor(args, opts) {
super(args, opts);
// Define argument.
this.argument('arg1', { type: String, required: false });
// Define options
this.option('coffee', { type: String, required: false });
// And you can then access it later; e.g.
// this.log(this.options.arg1);
@alieslamifard
alieslamifard / yeoman-5.js
Created March 5, 2019 14:28
yeoman generator
writing() {
this.fs.copyTpl(this.templatePath('_data.json'), this.destinationPath('/data.json'), {
name: this.props.name,
cool: this.props.cool
});
}
@alieslamifard
alieslamifard / yeoman-4.js
Last active March 5, 2019 14:29
yeoman generator
{
"projectName": "<%= name %>",
"coolFeatures": <%= cool %>
}
@alieslamifard
alieslamifard / yeoman-3.js
Created March 5, 2019 14:27
yeoman generator
{
"projectName": "some-name",
"coolFeatures": true
}
@alieslamifard
alieslamifard / yeoman-2.js
Created March 5, 2019 14:26
yeoman generator
prompting() {
// Have Yeoman greet the user.
this.log(yosay(`Welcome from ${chalk.yellow('KIAN')} development team.`));
const prompts = [
{
type: 'input',
name: 'name',
message: 'project name?'
},
@alieslamifard
alieslamifard / yeoman-1.js
Created March 5, 2019 14:25
yeoman generator
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
module.exports = class extends Generator {...}
export function async someAction() {
const response = await someHelperFunctionThatCallAnotherService();
if (!response) {
return dispatch({
type: 'FAILURE'
})
}
// check schema
export function async someAction() {
const response = await someHelperFunctionThatCallAnotherService();
if (!response) {
return dispatch({
type: 'FAILURE'
})
}
return dispatch({
type: 'SUCCESS',
if ( foo?.bar?.length ) {
return foo.bar.map(items => <Component data={items.hey} />)
}