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

fix(bindings/node): Fix loading of spack.config.js #7105

Merged
merged 2 commits into from Mar 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions node-swc/src/spack.ts
Expand Up @@ -4,12 +4,15 @@ import { Options } from "./types";

export type BundleInput = BundleOptions | BundleOptions[];

export const isLocalFile = /^\.{0,2}\//; // starts with '/' './' '../'

export async function compileBundleOptions(config: BundleInput | string | undefined): Promise<BundleInput> {
const f = config === undefined ? '.' : config;

try {
const file = typeof f === 'string' ? f : path.resolve('spack.config.js');
let configFromFile: BundleInput = require(file);
const filepath = typeof f === 'string' ? f : 'spack.config.js';
const fileModule = isLocalFile.test(filepath) ? path.resolve(filepath) : filepath;
let configFromFile: BundleInput = require(fileModule);
if ((configFromFile as any).default) {
configFromFile = (configFromFile as any).default;
}
Expand Down