Skip to content

Commit

Permalink
fix: readdir error is causing cli commands to fail (#476)
Browse files Browse the repository at this point in the history
* fix: readdir error is causing cli commands to fail

* fix: add source-map-support to test-app dependencies

* fix: eslint error

* fix: correctly build external modules array
  • Loading branch information
zacharygolba authored Oct 20, 2016
1 parent 2deea84 commit f27eab4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/packages/compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import eslint from 'rollup-plugin-eslint';
import nodeResolve from 'rollup-plugin-node-resolve';
import { rollup } from 'rollup';

import { BACKSLASH } from '../../constants';
import { rmrf, readdir, readdirRec, isJSFile } from '../fs';
import { rmrf, exists, readdir, readdirRec, isJSFile } from '../fs';
import template from '../template';
import uniq from '../../utils/uniq';

import normalizePath from './utils/normalize-path';
import createManifest from './utils/create-manifest';
Expand All @@ -32,15 +32,17 @@ export async function compile(dir: string, env: string, {

const nodeModules = path.join(dir, 'node_modules');
const luxNodeModules = path.join(__dirname, '..', 'node_modules');
const sourceMapSupport = path.join(luxNodeModules, 'source-map-support');

const external = await Promise.all([
readdir(nodeModules),
readdir(luxNodeModules)
]).then(([a, b]: [Array<string>, Array<string>]) => (
a.concat(b).filter(name => name !== 'lux-framework')
let external = await readdir(nodeModules).then(files => (
files.filter(name => name !== 'lux-framework')
));

if (await exists(luxNodeModules)) {
external = uniq([
...external,
...(await readdir(luxNodeModules))
]);
}

const assets = await Promise.all([
readdir(path.join(dir, 'app', 'models')),
readdir(path.join(dir, 'db', 'migrate')),
Expand Down Expand Up @@ -76,7 +78,6 @@ export async function compile(dir: string, env: string, {
createManifest(dir, assets, {
useStrict
}),

createBootScript(dir, {
useStrict
})
Expand All @@ -86,7 +87,6 @@ export async function compile(dir: string, env: string, {
entry,
onwarn,
external,

plugins: [
alias({
resolve: ['.js'],
Expand Down Expand Up @@ -120,9 +120,7 @@ export async function compile(dir: string, env: string, {
await rmrf(entry);

banner = template`
const srcmap = require('${
sourceMapSupport.replace(BACKSLASH, '/')
}').install({
const srcmap = require('source-map-support').install({
environment: 'node'
});
`;
Expand Down
1 change: 1 addition & 0 deletions test/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"mssql": "3.3.0",
"mysql2": "1.1.1",
"pg": "6.1.0",
"source-map-support": "0.4.5",
"sqlite3": "3.1.6"
},
"devDependencies": {
Expand Down

0 comments on commit f27eab4

Please sign in to comment.