transpiler: normalize Dart library name

`file2module` was used for normalizing paths where `-` is fine.
This normalizes non-word characters only when generating the Dart
library name.
This commit is contained in:
Vojta Jina 2014-10-06 17:44:25 -07:00
parent cfc5fdc60d
commit 6efb7f9017
2 changed files with 1 additions and 4 deletions

View File

@ -1,8 +1,5 @@
function file2moduleName(filePath) {
return filePath
// module name should not include non word characters (e.g. '-')
// -> important for Dart
.replace(/[^\w.\/]/g, '_')
// module name should be relative to `modules` and `tools` folder
.replace(/.*\/modules\//, '')
.replace(/.*\/tools\//, '')

View File

@ -20,7 +20,7 @@ import {ParseTreeWriter as JavaScriptParseTreeWriter, ObjectLiteralExpression} f
export class DartParseTreeWriter extends JavaScriptParseTreeWriter {
constructor(moduleName, outputPath) {
super(outputPath);
this.libName = moduleName.replace(/\//g, '.');
this.libName = moduleName.replace(/\//g, '.').replace(/[^\w.\/]/g, '_');
}
// VARIABLES - types