Skip to content

Commit

Permalink
Merge branch 'fix-build'
Browse files Browse the repository at this point in the history
* fix-build:
  fix(build): work around an issue with `env` on Travis CI build setup
  • Loading branch information
eventualbuddha committed Jun 23, 2016
2 parents c62e1f2 + 7cde200 commit b01e08e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ notifications:
node_js:
- '6'
- '4'
- '0.12'
before_install:
- npm i -g npm@^2.0.0
before_script:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"jsnext:main": "dist/decaffeinate-traverse.mjs",
"scripts": {
"prebuild": "rm -rf dist/ && mkdir -p dist/",
"build": "./script/build && rollup -c",
"build": "node -r babel-register ./script/build && rollup -c",
"preflow": "npm run build",
"flow": "flow check",
"test": "mocha",
Expand Down
32 changes: 16 additions & 16 deletions script/build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node -r babel-register
#!/usr/bin/env node

import { createWriteStream } from 'fs';
import { join } from 'path';
Expand Down Expand Up @@ -30,14 +30,14 @@ let getType = memoize(name => types.find(t => t.name === name));

let expandType = memoize(name => {
let type = Object.assign({}, getType(name));

if (type.extends) {
type.properties = [
...type.properties,
...expandType(type.extends).properties
];
}

return type;
});

Expand All @@ -52,7 +52,7 @@ function expandTypes(types) {

function getAncestorTypes(name) {
let type = getType(name);

if (!type.extends) {
return [];
} else {
Expand Down Expand Up @@ -83,11 +83,11 @@ function unionTypes(types) {
});

let result = [];

unionMap.forEach((types, name) => {
result.push({ name, types });
});

return result;
}

Expand All @@ -103,18 +103,18 @@ function containsNodeType(typeSignature) {
switch (flowType && flowType.type) {
case 'NullableTypeAnnotation':
return flowTypeContainsNodeType(flowType.typeAnnotation);

case 'UnionTypeAnnotation':
return flowType.types.some(flowTypeContainsNodeType);

case 'GenericTypeAnnotation':
return allNodeTypes.has(flowType.id.name) || flowTypeContainsNodeType(flowType.typeParameters);

case 'TypeParameterInstantiation':
return flowType.params.some(flowTypeContainsNodeType);
}
}

return flowTypeContainsNodeType(parseFlowTypeSignature(typeSignature));
}

Expand All @@ -137,7 +137,7 @@ expandedTypes

unions.forEach(type => {
interfaceFile.write(`declare type ${getTypeSymbol(type.name)} =\n`);

type.types.forEach((type, i, types) => {
if (i === types.length - 1) {
interfaceFile.write(` ${getTypeSymbol(type)};\n\n`);
Expand Down Expand Up @@ -209,18 +209,18 @@ expandedTypes
.filter(type => !type.abstract)
.forEach((type, i, types) => {
let visitsChildren = false;

visitorFile.write(` visit${type.name}(node: ${getTypeSymbol(type.name)}) {\n`);
type.properties.forEach(property => {
let match = property.type.match(/^Array<(.+)>$/);
let type = property.type;
let isArray = false;

if (match) {
type = match[1];
isArray = true;
}

if (containsNodeType(type)) {
visitsChildren = true;
let visitor = 'descend';
Expand All @@ -242,11 +242,11 @@ expandedTypes
}
}
});

if (!visitsChildren) {
visitorFile.write(` // no children\n`);
}

visitorFile.write(` }\n`);
if (i !== types.length - 1) {
visitorFile.write(`\n`);
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* @flow */

export { default as Visitor } from './visitor.js';
export { default as Visitor } from './Visitor.js';
export { default as traverse } from './traverse.js';

0 comments on commit b01e08e

Please sign in to comment.