Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Windows fixes #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion build/import-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

const path = require('path');
const path = require('path').posix; // Windows fix: .posix makes paths use '/' instead of '\', and solves issues linked to that.

const alreadyResolvedMatch = /^(\.{0,2}\/|[a-z]\w*\:)/; // matches start of './' or 'https:' etc

Expand Down
2 changes: 1 addition & 1 deletion build/modern-vfs-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const modernLoader = require('./modern-loader.js');
const mimeTypes = require('mime-types');
const path = require('path');
const path = require('path').posix; // Windows fix: .posix makes paths use '/' instead of '\', and solves issues linked to that.
const fs = require('fs').promises;


Expand Down
8 changes: 4 additions & 4 deletions santa-vfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

const fsp = require('./build/fsp.js');
const path = require('path');
const path = require('path').posix; // Windows fix: .posix makes paths use '/' instead of '\', and solves issues linked to that.
const compileStyles = require('./build/compile-santa-sass.js');
const compileScene = require('./build/compile-scene.js');
const JSON5 = require('json5');
Expand Down Expand Up @@ -174,7 +174,7 @@ module.exports = (staticScope, options) => {

// TODO(samthor): Closure doesn't have to be tied to scenes. But, it's mostly for historic code,
// so maybe it's not worth making it generic.
const closureSceneMatch = /^static\/scenes\/(\w+)\/:closure(|-\w+)\.js$/;
const closureSceneMatch = /(static\/scenes\/(\w+)\/:closure(|-\w+)\.js)/; // Old regex didn't detect closure paths correctly
const closurePlugin = {
match(id) {
const rooted = path.relative(__dirname, id);
Expand All @@ -185,9 +185,9 @@ module.exports = (staticScope, options) => {
},
async load(id) {
const m = closureSceneMatch.exec(id);
const sceneName = m[1];
const sceneName = m[2]; // Was m[1]

const flags = m[2];
const flags = m[3]; // Was m[2]
if (flags) {
// nb. This previously allowed e.g., ':closure-typeSafe.js'.
throw new Error(`unsupported Closure flags: ${flags}`);
Expand Down
8 changes: 4 additions & 4 deletions serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ const yargs = require('yargs')
default: false,
describe: 'Serve static on network address'
})
.option('prefix', {
/*.option('prefix', { // Prefix removed to solve the issue with js files going outside of the prefix and not being able to get the files
type: 'string',
default: 'st',
describe: 'Static prefix',
coerce(v) {
return v.replace(/[^a-z0-9]/g, '') || 'st'; // ensure prefix is basic ascii only
},
requiresArg: true,
})
})*/
.option('lang', {
type: 'string',
default: 'en',
Expand Down Expand Up @@ -92,7 +92,7 @@ log(chalk.red(messages('santatracker')), `[${yargs.lang}]`);
// nb. matches config in release.js
const baseurl = `http://127.0.0.1:${yargs.port + 80}/`;
const config = {
staticScope: `${baseurl}${yargs.prefix}/`,
staticScope: `${baseurl}`, // Prefix removed to solve the issue with js files going outside of the prefix and not being able to get the files
version: `dev-${(new Date).toISOString().replace(/[^\d]/g, '')}`,
baseurl,
};
Expand All @@ -110,7 +110,7 @@ async function serve() {
serveLink: true,
});
const staticServer = polka();
staticServer.use(yargs.prefix, vfsMiddleware(vfs, 'static'), staticHost);
staticServer.use('/', vfsMiddleware(vfs, 'static'), staticHost); // Prefix removed to solve the issue with js files going outside of the prefix and not being able to get the files

await listen(staticServer, yargs.port + 80, yargs.all);
log('Static', chalk.green(config.staticScope), yargs.all ? chalk.red('(on all interfaces)') : '');
Expand Down