-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexamples.js
100 lines (90 loc) · 1.99 KB
/
examples.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
var path = require('path');
var gm = require('global-modules');
var stringify = require('./test/support/');
var Scaffold = require('./');
/**
* UI component
*/
var npm = new Scaffold({
options: {a: 'b'},
component: {
options: {
data: {title: 'Foo'},
cwd: gm + '/scaffolds-example/scaffolds',
expand: true,
},
files: [
{src: 'templates/*.hbs', dest: 'src/'},
{src: 'scripts/*.js', dest: 'src/'},
{src: 'styles/*.css', dest: 'src/', options: {data: {title: 'Bar'}}},
]
}
});
console.log(stringify(npm));
/**
* Site components
*/
var site = new Scaffold({
blog: {
cwd: 'test/scaffolds',
files: [
{src: 'content/post.md', dest: 'src/posts/'},
{src: 'scripts/*.js', dest: 'src/scripts/'},
{src: 'data/ipsum.json', dest: 'src/data/'}
]
},
components: {
cwd: 'test/scaffolds',
files: [
{src: 'content/post.md', dest: 'src/posts/'},
{src: 'scripts/*.js', dest: 'src/scripts/'},
{src: 'data/ipsum.json', dest: 'src/data/'}
]
}
});
console.log(stringify(site));
/**
* Dotfiles
*/
var dotfiles = new Scaffold({
root: {
src: '.*',
filter: function(fp) {
return !/DS_Store/.test(fp);
}
}
});
console.log(stringify(dotfiles));
// `~` tilde expands to the user's home directory
var home = new Scaffold({
foo: {
options: {cwd: '~/scaffolds'},
src: ['**/component*'],
dest: 'local/src/'
},
bar: {
options: {cwd: '~', srcBase: 'scaffolds'},
src: ['*/component.*'],
dest: 'local/src/'
}
});
console.log(stringify(home))
function component(name) {
var scaffold = {};
scaffold[name] = {
files: {
src: ['*.js'],
dest: 'src'
},
rename: function(dest, src, opts) {
return path.join(dest, name, 'index') + path.extname(src);
}
};
return new Scaffold(scaffold);
}
console.log(component('foo'));
//=> 'src/foo/index.js'
console.log(component('bar'));
//=> 'src/bar/index.js'
console.log(component('baz'));
//=> 'src/baz/index.js'