-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathindex.js
60 lines (52 loc) · 1.12 KB
/
index.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
import path from 'path';
import chalk from 'chalk';
import dateformat from 'dateformat';
import vfs from 'vinyl-fs';
import through from 'through2';
import sassdoc from '../src/sassdoc';
function devLog(...args) {
console.log(...[
chalk.styles.inverse.open,
`[${dateformat(new Date(), 'HH:MM:ss')}]`,
...args,
chalk.styles.inverse.close
]);
}
function inspect() {
let count = 0;
return through.obj((chunk, enc, cb) => {
count++;
cb(null, chunk);
}, (cb) => {
devLog(`develop:stream:count:${count}`);
cb();
});
}
function documentize() {
return sassdoc('./test/data', { verbose: true })
.then(() => {
devLog('develop:documentize:end');
});
}
function stream() {
let parse = sassdoc({ verbose: true });
vfs.src('./test/data/**/*.scss')
.pipe(parse)
.on('end', () => {
devLog('develop:stream:end');
})
.pipe(inspect())
.on('data', () => {});
return parse.promise.then(() => {
devLog('develop:stream:promise:end');
});
}
(async function () {
try {
await documentize();
await stream();
}
catch (err) {
console.error(err);
}
}());