daf0f472b3
Our style guide includes formatting conventions. Instead of wasting time in reviewing PRs discussing things like indenting, and to avoid later deltas to fix bad formatting in earlier commits, we want to enforce these in the build. The intent in this change is to fail the build as quickly as possible in travis, so those sending a PR immediately know they should run clang-format and update their commit. When running locally, we want users to know about formatting, but they may not want to act on it immediately, until they are done working. For this reason, it is only a warning outside of the continuous build. This is done by having a check-format task which should run on most local builds, and an enforce-format task only run by travis.
44 lines
1.7 KiB
JavaScript
44 lines
1.7 KiB
JavaScript
// Brocfile to transpile sources from TypeScript to Dart using ts2dart.
|
|
var Funnel = require('broccoli-funnel');
|
|
var stew = require('broccoli-stew');
|
|
var ts2dart = require('./dist/broccoli/broccoli-ts2dart');
|
|
var path = require('path');
|
|
|
|
// Transpile everything in 'modules'...
|
|
var modulesTree = new Funnel('modules', {
|
|
include: ['**/*.js', '**/*.ts', '**/*.dart'], // .dart file available means don't translate.
|
|
exclude: ['rtts_assert/**/*'], // ... except for the rtts_asserts (don't apply to Dart).
|
|
destDir: '/', // Remove the 'modules' prefix.
|
|
});
|
|
|
|
// Transpile to dart.
|
|
var dartTree = ts2dart.transpile(modulesTree);
|
|
|
|
// Move around files to match Dart's layout expectations.
|
|
dartTree = stew.rename(dartTree, function(relativePath) {
|
|
// If a file matches the `pattern`, insert the given `insertion` as the second path part.
|
|
var replacements = [
|
|
{pattern: /^benchmarks\/test\//, insertion: ''},
|
|
{pattern: /^benchmarks\//, insertion: 'web'},
|
|
{pattern: /^benchmarks_external\/test\//, insertion: ''},
|
|
{pattern: /^benchmarks_external\//, insertion: 'web'},
|
|
{pattern: /^example.?\//, insertion: 'web/'},
|
|
{pattern: /^example.?\/test\//, insertion: ''},
|
|
{pattern: /^[^\/]*\/test\//, insertion: ''},
|
|
{pattern: /^./, insertion: 'lib'}, // catch all.
|
|
];
|
|
|
|
for (var i = 0; i < replacements.length; i++) {
|
|
var repl = replacements[i];
|
|
if (relativePath.match(repl.pattern)) {
|
|
var parts = relativePath.split('/');
|
|
parts.splice(1, 0, repl.insertion);
|
|
return path.join.apply(path, parts);
|
|
}
|
|
}
|
|
throw new Error('Failed to match any path', relativePath);
|
|
});
|
|
|
|
// Move the tree under the 'dart' folder.
|
|
module.exports = stew.mv(dartTree, 'dart');
|