Skip to content

Commit

Permalink
fix(playground): Dashboard doesn't work on Windows
Browse files Browse the repository at this point in the history
Fixes #82
  • Loading branch information
paveltiunov committed Apr 24, 2019
1 parent d1dbf25 commit 7c48aa4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions packages/cubejs-playground/src/DashboardSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ class DashboardSource {
}
}
});
if (!this.appClass) {
traverse(this.appAst, {
FunctionDeclaration: (path) => {
if (path.get('id').node.name === 'App') {
this.appClass = path;
}
}
});
}
if (!this.appClass) {
throw new Error(`App class not found. Can't parse dashboard app.`);
}
}

ensureDashboardIsInApp() {
Expand Down
7 changes: 5 additions & 2 deletions packages/cubejs-server-core/core/DevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class DevServer {
if (!stats.isDirectory()) {
const content = await fs.readFile(fileName, "utf-8");
return [{
fileName, content
fileName: fileName.replace(dashboardAppPath, '').replace(/\\/g, '/'),
content
}];
}
return [];
Expand All @@ -141,7 +142,9 @@ class DevServer {
app.post('/playground/dashboard-app-files', catchErrors(async (req, res) => {
this.cubejsServer.event('Dev Server App File Write');
const { files } = req.body;
await Promise.all(files.map(file => fs.writeFile(path.join(file.fileName), file.content)));
await Promise.all(
files.map(file => path.join(...[dashboardAppPath].concat(file.fileName.split('/'))))
);
res.json({ files });
}));

Expand Down

0 comments on commit 7c48aa4

Please sign in to comment.