-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
83 lines (68 loc) · 2.49 KB
/
gulpfile.babel.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
/**
* Please see `typhonjs-github-orgs-gulptasks` (https://www.npmjs.com/package/typhonjs-github-orgs-gulptasks)
*/
import fs from 'fs';
import gulp from 'gulp';
import gulpTasks from './src/index.js';
import taskListing from 'gulp-task-listing';
// Loads owner / user public access tokens from environment variables or from `./token.owner` and `./token.user` in
// the root directory.
let ownerCredential = process.env.GITHUB_OWNER_TOKEN;
let userCredential = process.env.GITHUB_USER_TOKEN;
// If user ownerCredential is still undefined attempt to load from a local file `./owner.token`.
if (typeof ownerCredential === 'undefined')
{
try { ownerCredential = fs.readFileSync('./token.owner', 'utf-8'); }
catch (err) { /* ... */ }
}
// If user userCredential is still undefined attempt to load from a local file `./user.token`.
if (typeof userCredential === 'undefined')
{
try { userCredential = fs.readFileSync('./token.user', 'utf-8'); }
catch (err) { /* ... */ }
}
// Fail now if we don't have an owner token.
if (typeof ownerCredential !== 'string')
{
throw new TypeError('No owner credentials found in `process.env.GITHUB_OWNER_TOKEN` or `./token.owner`.');
}
// Fail now if we don't have a user token.
if (typeof userCredential !== 'string')
{
throw new TypeError('No user credentials found in `process.env.GITHUB_USER_TOKEN` or `./token.user`.');
}
// Defines TyphonJS organizations.
const organizations = [{ credential: ownerCredential, owner: 'typhonrt', regex: '^typhonjs' }];
// Import all tasks and set `rootPath` to the base project path and `srcGlob` to all JS sources in `./src`.
gulpTasks(gulp,
{
rootPath: __dirname,
importTasks: ['transform'],
inspectOptions: { ctor: { organizations, verbose: true } },
transformOptions: { ctor: { transformType: 'markdown' }, methods: { credential: userCredential, description: true } }
});
// For testing ------------------------------------------------------------------------------------------------------
/**
* Generates task listing
*/
gulp.task('local-test', () =>
{
taskListing.withFilters(null, ['local-test', 'verify-test'])();
});
/**
* Verifies task listing data
*/
gulp.task('verify-test', () =>
{
const testData = fs.readFileSync('./test/testdata.txt', 'utf8');
const matchData = fs.readFileSync('./test/matchdata.txt', 'utf8');
if (matchData !== testData)
{
console.log('Verification failed');
process.exit(1);
}
else
{
console.log('Verification passed');
}
});