Skip to content

Commit

Permalink
Resolves #188, upgrade to Asciidoctor.js 1.5.6-rc.1
Browse files Browse the repository at this point in the history
* Remove 'bestikk-opal-compiler' dependency (we now use 'opal-compiler' directly)
* Remove async dependency (not used anymore)
* Simplify build scripts and use ECMAScript 6 syntax
* Run the task examples on Travis
* The examples task does not run the task build anymore
  • Loading branch information
ggrossetie committed Mar 25, 2018
1 parent 3d2a945 commit 249e026
Show file tree
Hide file tree
Showing 8 changed files with 592 additions and 125 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ script:
- npm install
- bundle exec rake build:converter:opal
- npm run build
- npm run examples
- npm test

notifications:
Expand Down
41 changes: 38 additions & 3 deletions npm/build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
var Builder = require('./builder.js');
var builder = new Builder();
const log = require('bestikk-log');
const bfs = require('bestikk-fs');
const CompilerModule = require('./compiler.js');

builder.build();
const clean = function () {
log.task('clean');
removeBuildDirSync(); // remove build directory
};

const removeBuildDirSync = function () {
log.debug('remove build directory');
bfs.removeSync('build');
bfs.mkdirsSync('build');
};

const compile = function () {
CompilerModule.compile();
};

const copyToDist = function () {
log.task('copy to dist/');
removeDistDirSync();
bfs.copySync('build/asciidoctor-reveal.js', 'dist/main.js');
};

const removeDistDirSync = function () {
log.debug('remove dist directory');
bfs.removeSync('dist');
bfs.mkdirsSync('dist');
};

if (process.env.SKIP_BUILD) {
log.info('SKIP_BUILD environment variable is true, skipping "build" task');
return;
}

clean();
compile();
copyToDist();
114 changes: 0 additions & 114 deletions npm/builder.js

This file was deleted.

15 changes: 15 additions & 0 deletions npm/compiler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require('fs');
const log = require('bestikk-log');
const OpalBuilder = require('opal-compiler').Builder;

module.exports.compile = function () {
log.task('compile');

const opalBuilder = OpalBuilder.create();
opalBuilder.appendPaths('lib');
opalBuilder.setCompilerOptions({dynamic_require_severity: 'ignore'});
const module = 'asciidoctor-revealjs';
log.debug(module);
const data = opalBuilder.build(module).toString();
fs.writeFileSync('build/asciidoctor-reveal.js', data, 'utf8');
};
29 changes: 26 additions & 3 deletions npm/examples.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
const fs = require('fs');
const path = require('path');
const log = require('bestikk-log');
const Builder = require('./builder.js');
const builder = new Builder();

const examplesDir = 'examples';

log.task('examples');
builder.examples();

// Load asciidoctor.js and local asciidoctor-reveal.js
const asciidoctor = require('asciidoctor.js')();
require('../build/asciidoctor-reveal.js');

// Convert *a* document using the reveal.js converter
var attributes = {'revealjsdir': 'node_modules/reveal.js@'};
var options = {safe: 'safe', backend: 'revealjs', attributes: attributes, to_dir: examplesDir};

fs.readdir(examplesDir, (err, files) => {
files.forEach(function (filename) {
if (path.extname(filename) === '.adoc') {
try {
asciidoctor.convertFile(path.join(examplesDir, filename), options);
log.info(`Successfully converted ${filename}`);
}
catch (err) {
log.error(`Error converting ${filename}: ${err}`);
}
}
});
});
Loading

0 comments on commit 249e026

Please sign in to comment.