2 let path = require('path');
3 let proc = require('child_process');
5 const PROJECT_DIR = process.cwd();
6 process.env.PROJECT_DIR = PROJECT_DIR;
8 namespace('doc', function () {
9 task('generate', ['doc:clobber'], function () {
10 var cmd = '../node-jsdoc-toolkit/app/run.js -n -r=100 ' +
11 '-t=../node-jsdoc-toolkit/templates/codeview -d=./doc/ ./lib';
12 jake.logger.log('Generating docs ...');
13 jake.exec([cmd], function () {
14 jake.logger.log('Done.');
19 task('clobber', function () {
20 var cmd = 'rm -fr ./doc/*';
21 jake.exec([cmd], function () {
22 jake.logger.log('Clobbered old docs.');
29 desc('Generate docs for Jake');
30 task('doc', ['doc:generate']);
32 npmPublishTask('jake', function () {
33 this.packageFiles.include([
43 this.packageFiles.exclude([
48 jake.Task['publish:package'].directory = PROJECT_DIR;
50 namespace('test', function () {
52 let integrationTest = task('integration', ['publish:package'], async function () {
53 let pkg = JSON.parse(fs.readFileSync(`${PROJECT_DIR}/package.json`).toString());
54 let version = pkg.version;
56 proc.execSync('rm -rf ./node_modules');
57 // Install from the actual package, run tests from the packaged binary
58 proc.execSync(`mkdir -p node_modules/.bin && mv ${PROJECT_DIR}/pkg/jake-v` +
59 `${version} node_modules/jake && ln -s ${process.cwd()}` +
60 '/node_modules/jake/bin/cli.js ./node_modules/.bin/jake');
63 if (process.env.filter) {
64 testArgs.push(process.env.filter);
67 testArgs.push('*.js');
69 let spawned = proc.spawn(`${PROJECT_DIR}/node_modules/.bin/mocha`, testArgs, {
72 return new Promise((resolve, reject) => {
73 spawned.on('exit', () => {
74 if (!(process.env.noclobber || process.env.noClobber)) {
75 proc.execSync('rm -rf tmp_publish && rm -rf package.json' +
76 ' && rm -rf package-lock.json && rm -rf node_modules');
77 // Rather than invoking 'clobber' task
78 jake.rmRf(`${PROJECT_DIR}/pkg`);
86 integrationTest.directory = `${PROJECT_DIR}/test/integration`;
88 let unitTest = task('unit', async function () {
90 if (process.env.filter) {
91 testArgs.push(process.env.filter);
94 testArgs.push('*.js');
96 let spawned = proc.spawn(`${PROJECT_DIR}/node_modules/.bin/mocha`, testArgs, {
101 unitTest.directory = `${PROJECT_DIR}/test/unit`;
104 desc('Runs all tests');
105 task('test', ['test:unit', 'test:integration']);