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

Bump gts from 5.3.1 to 6.0.2 #345

Merged
merged 4 commits into from
Nov 4, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
_types
build
dist
lib/src/vendor
Expand Down
2 changes: 1 addition & 1 deletion bin/sass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ try {
{
stdio: 'inherit',
windowsHide: true,
}
},
);
} catch (error) {
if (error.code) {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export {NodePackageImporter} from './importer-registry';

export function compile(
path: string,
options?: OptionsWithLegacy<'sync'>
options?: OptionsWithLegacy<'sync'>,
): CompileResult {
const compiler = initCompiler();
try {
Expand All @@ -23,7 +23,7 @@ export function compile(

export function compileString(
source: string,
options?: StringOptionsWithLegacy<'sync'>
options?: StringOptionsWithLegacy<'sync'>,
): CompileResult {
const compiler = initCompiler();
try {
Expand All @@ -35,7 +35,7 @@ export function compileString(

export async function compileAsync(
path: string,
options?: OptionsWithLegacy<'async'>
options?: OptionsWithLegacy<'async'>,
): Promise<CompileResult> {
const compiler = await initAsyncCompiler();
try {
Expand All @@ -47,7 +47,7 @@ export async function compileAsync(

export async function compileStringAsync(
source: string,
options?: StringOptionsWithLegacy<'async'>
options?: StringOptionsWithLegacy<'async'>,
): Promise<CompileResult> {
const compiler = await initAsyncCompiler();
try {
Expand Down
12 changes: 6 additions & 6 deletions lib/src/compiler-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function isLinuxMusl(path: string): boolean {
return p.basename(interpreter).startsWith('ld-musl-');
} catch (error) {
console.warn(
`Warning: Failed to detect linux-musl, fallback to linux-gnu: ${error.message}`
`Warning: Failed to detect linux-musl, fallback to linux-gnu: ${error.message}`,
);
return false;
}
Expand All @@ -37,7 +37,7 @@ export const compilerCommand = (() => {
const executable = p.resolve(
__dirname,
path,
`dart-sass/sass${platform === 'win32' ? '.bat' : ''}`
`dart-sass/sass${platform === 'win32' ? '.bat' : ''}`,
);

if (fs.existsSync(executable)) return [executable];
Expand All @@ -47,10 +47,10 @@ export const compilerCommand = (() => {
return [
require.resolve(
`sass-embedded-${platform}-${arch}/dart-sass/src/dart` +
(platform === 'win32' ? '.exe' : '')
(platform === 'win32' ? '.exe' : ''),
),
require.resolve(
`sass-embedded-${platform}-${arch}/dart-sass/src/sass.snapshot`
`sass-embedded-${platform}-${arch}/dart-sass/src/sass.snapshot`,
),
];
} catch (ignored) {
Expand All @@ -61,7 +61,7 @@ export const compilerCommand = (() => {
return [
require.resolve(
`sass-embedded-${platform}-${arch}/dart-sass/sass` +
(platform === 'win32' ? '.bat' : '')
(platform === 'win32' ? '.bat' : ''),
),
];
} catch (e: unknown) {
Expand All @@ -74,6 +74,6 @@ export const compilerCommand = (() => {
"Embedded Dart Sass couldn't find the embedded compiler executable. " +
'Please make sure the optional dependency ' +
`sass-embedded-${platform}-${arch} is installed in ` +
'node_modules.'
'node_modules.',
);
})();
4 changes: 2 additions & 2 deletions lib/src/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ describe('asyncCompiler', () => {
describe('compilation ID', () => {
it('resets after concurrent compilations complete', async () => {
await Promise.all(
Array.from({length: 10}, () => asyncCompiler.compileStringAsync(''))
Array.from({length: 10}, () => asyncCompiler.compileStringAsync('')),
);
await asyncCompiler.compileStringAsync('');
expect(getIdHistory()).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]);
});

it('keeps working after failed compilations', async () => {
await expect(
asyncCompiler.compileStringAsync('invalid')
asyncCompiler.compileStringAsync('invalid'),
).rejects.toThrow();
await Promise.all([
asyncCompiler.compileStringAsync(''),
Expand Down
22 changes: 11 additions & 11 deletions lib/src/compiler/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export class AsyncCompiler {
cwd: path.dirname(compilerCommand[0]),
// Node blocks launching .bat and .cmd without a shell due to CVE-2024-27980
shell: ['.bat', '.cmd'].includes(
path.extname(compilerCommand[0]).toLowerCase()
path.extname(compilerCommand[0]).toLowerCase(),
),
windowsHide: true,
}
},
);

/** The next compilation ID. */
Expand Down Expand Up @@ -101,7 +101,7 @@ export class AsyncCompiler {
private async compileRequestAsync(
request: proto.InboundMessage_CompileRequest,
importers: ImporterRegistry<'async'>,
options?: OptionsWithLegacy<'async'> & {legacy?: boolean}
options?: OptionsWithLegacy<'async'> & {legacy?: boolean},
): Promise<CompileResult> {
const optionsKey = Symbol();
activeDeprecationOptions.set(optionsKey, options ?? {});
Expand All @@ -116,7 +116,7 @@ export class AsyncCompiler {
handleFileImportRequest: request => importers.fileImport(request),
handleCanonicalizeRequest: request => importers.canonicalize(request),
handleFunctionCallRequest: request => functions.call(request),
}
},
);
dispatcher.logEvents$.subscribe(event => handleLogEvent(options, event));

Expand All @@ -133,7 +133,7 @@ export class AsyncCompiler {
} else {
resolve(response!);
}
})
}),
);
this.compilations.add(compilation);

Expand All @@ -148,7 +148,7 @@ export class AsyncCompiler {
if (flag !== initFlag) {
throw utils.compilerError(
'AsyncCompiler can not be directly constructed. ' +
'Please use `sass.initAsyncCompiler()` instead.'
'Please use `sass.initAsyncCompiler()` instead.',
);
}
this.stderr$.subscribe(data => process.stderr.write(data));
Expand All @@ -157,33 +157,33 @@ export class AsyncCompiler {
});
this.messageTransformer = new MessageTransformer(
packetTransformer.outboundProtobufs$,
packet => packetTransformer.writeInboundProtobuf(packet)
packet => packetTransformer.writeInboundProtobuf(packet),
);
}

compileAsync(
path: string,
options?: OptionsWithLegacy<'async'>
options?: OptionsWithLegacy<'async'>,
): Promise<CompileResult> {
this.throwIfDisposed();
const importers = new ImporterRegistry(options);
return this.compileRequestAsync(
newCompilePathRequest(path, importers, options),
importers,
options
options,
);
}

compileStringAsync(
source: string,
options?: StringOptionsWithLegacy<'async'>
options?: StringOptionsWithLegacy<'async'>,
): Promise<CompileResult> {
this.throwIfDisposed();
const importers = new ImporterRegistry(options);
return this.compileRequestAsync(
newCompileStringRequest(source, importers, options),
importers,
options
options,
);
}

Expand Down
16 changes: 8 additions & 8 deletions lib/src/compiler/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export class Compiler {
cwd: path.dirname(compilerCommand[0]),
// Node blocks launching .bat and .cmd without a shell due to CVE-2024-27980
shell: ['.bat', '.cmd'].includes(
path.extname(compilerCommand[0]).toLowerCase()
path.extname(compilerCommand[0]).toLowerCase(),
),
windowsHide: true,
}
},
);

/** The next compilation ID. */
Expand Down Expand Up @@ -107,7 +107,7 @@ export class Compiler {
private compileRequestSync(
request: proto.InboundMessage_CompileRequest,
importers: ImporterRegistry<'sync'>,
options?: OptionsWithLegacy<'sync'>
options?: OptionsWithLegacy<'sync'>,
): CompileResult {
const optionsKey = Symbol();
activeDeprecationOptions.set(optionsKey, options ?? {});
Expand All @@ -122,7 +122,7 @@ export class Compiler {
handleFileImportRequest: request => importers.fileImport(request),
handleCanonicalizeRequest: request => importers.canonicalize(request),
handleFunctionCallRequest: request => functions.call(request),
}
},
);
this.dispatchers.add(dispatcher);

Expand Down Expand Up @@ -168,7 +168,7 @@ export class Compiler {
if (flag !== initFlag) {
throw utils.compilerError(
'Compiler can not be directly constructed. ' +
'Please use `sass.initAsyncCompiler()` instead.'
'Please use `sass.initAsyncCompiler()` instead.',
);
}
this.stderr$.subscribe(data => process.stderr.write(data));
Expand All @@ -177,7 +177,7 @@ export class Compiler {
});
this.messageTransformer = new MessageTransformer(
packetTransformer.outboundProtobufs$,
packet => packetTransformer.writeInboundProtobuf(packet)
packet => packetTransformer.writeInboundProtobuf(packet),
);
}

Expand All @@ -187,7 +187,7 @@ export class Compiler {
return this.compileRequestSync(
newCompilePathRequest(path, importers, options),
importers,
options
options,
);
}

Expand All @@ -197,7 +197,7 @@ export class Compiler {
return this.compileRequestSync(
newCompileStringRequest(source, importers, options),
importers,
options
options,
);
}

Expand Down
18 changes: 9 additions & 9 deletions lib/src/compiler/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ export type StringOptionsWithLegacy<sync extends 'sync' | 'async'> =
export function createDispatcher<sync extends 'sync' | 'async'>(
compilationId: number,
messageTransformer: MessageTransformer,
handlers: DispatcherHandlers<sync>
handlers: DispatcherHandlers<sync>,
): Dispatcher<sync> {
return new Dispatcher<sync>(
compilationId,
messageTransformer.outboundMessages$,
message => messageTransformer.writeInboundMessage(message),
handlers
handlers,
);
}

// Creates a compilation request for the given `options` without adding any
// input-specific options.
function newCompileRequest(
importers: ImporterRegistry<'sync' | 'async'>,
options?: Options<'sync' | 'async'>
options?: Options<'sync' | 'async'>,
): proto.InboundMessage_CompileRequest {
const request = create(proto.InboundMessage_CompileRequestSchema, {
importers: importers.importers,
Expand Down Expand Up @@ -103,7 +103,7 @@ function newCompileRequest(
export function newCompilePathRequest(
path: string,
importers: ImporterRegistry<'sync' | 'async'>,
options?: Options<'sync' | 'async'>
options?: Options<'sync' | 'async'>,
): proto.InboundMessage_CompileRequest {
const absPath = p.resolve(path);
const request = newCompileRequest(importers, options);
Expand All @@ -115,7 +115,7 @@ export function newCompilePathRequest(
export function newCompileStringRequest(
source: string,
importers: ImporterRegistry<'sync' | 'async'>,
options?: StringOptions<'sync' | 'async'>
options?: StringOptions<'sync' | 'async'>,
): proto.InboundMessage_CompileRequest {
const input = create(proto.InboundMessage_CompileRequest_StringInputSchema, {
source,
Expand All @@ -134,7 +134,7 @@ export function newCompileStringRequest(
proto.InboundMessage_CompileRequest_ImporterSchema,
{
importer: {case: 'path', value: p.resolve('.')},
}
},
);
} else {
// When importer is not set on the host, the compiler will set a
Expand All @@ -148,15 +148,15 @@ export function newCompileStringRequest(

/** Type guard to check that `id` is a valid deprecation ID. */
function validDeprecationId(
id: string | number | symbol | undefined
id: string | number | symbol | undefined,
): id is keyof typeof deprecations {
return !!id && id in deprecations;
}

/** Handles a log event according to `options`. */
export function handleLogEvent(
options: OptionsWithLegacy<'sync' | 'async'> | undefined,
event: proto.OutboundMessage_LogEvent
event: proto.OutboundMessage_LogEvent,
): void {
let span = event.span ? deprotofySourceSpan(event.span) : null;
if (span && options?.legacy) span = removeLegacyImporterFromSpan(span);
Expand Down Expand Up @@ -210,7 +210,7 @@ export function handleLogEvent(
* Throws a `SassException` if the compilation failed.
*/
export function handleCompileResponse(
response: proto.OutboundMessage_CompileResponse
response: proto.OutboundMessage_CompileResponse,
): CompileResult {
if (response.result.case === 'success') {
const success = response.result.value;
Expand Down
Loading