Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

respect custom basepaths #29

Merged
merged 1 commit into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/project/panes/App/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,16 @@
},

async editPage() {
const { dir } = this.store.get();
const { basepath = '', dir } = this.store.get();
const { find_page } = relative('sapper/api.js', dir);
const { status: pathname } = this.get(); // bit of a hack — proxy for pathname
const files = glob('**', { cwd: path.resolve(dir, 'routes'), filesOnly: true, dot: true });

let { status: pathname } = this.get(); // bit of a hack — proxy for pathname

if (pathname.startsWith(basepath)) {
pathname = pathname.slice(basepath.length);
}

const page = find_page(pathname, files);

if (page) {
Expand Down
7 changes: 5 additions & 2 deletions src/project/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ class StudioStore extends Store {
break;

case 'error':
console.log(`error ${message.error.message}`);
console.log(`error ${message.error.message}`);
break;

case 'ready':
setTimeout(() => {
console.log('message', message.port);
this.set({
startingDev: false,
runningDev: true,
Expand All @@ -108,6 +107,10 @@ class StudioStore extends Store {
port: message.port
});
});
break;

case 'basepath':
this.set({ basepath: message.event.basepath });

break;
}
Expand Down
31 changes: 6 additions & 25 deletions workers/sapper-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,11 @@ watcher.on('ready', event => {
});
});

watcher.on('error', event => {
process.send({
type: 'error',
event
});
});

watcher.on('fatal', event => {
process.send({
type: 'fatal',
event
});
});

watcher.on('invalid', event => {
process.send({
type: 'invalid',
event
});
});

watcher.on('build', event => {
process.send({
type: 'build',
event
['error', 'fatal', 'invalid', 'build', 'basepath'].forEach(type => {
watcher.on(type, event => {
process.send({
type,
event
});
});
});