Skip to content

Commit 80f5a20

Browse files
authored
Parse Deprecation.forVersion on compiler side (#299)
1 parent 82e1590 commit 80f5a20

File tree

4 files changed

+6
-21
lines changed

4 files changed

+6
-21
lines changed

lib/src/deprecations.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,12 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5-
import {deprecations} from './vendor/deprecations';
6-
import {Deprecation, DeprecationOrId} from './vendor/sass';
5+
import {DeprecationOrId} from './vendor/sass';
76
import {Version} from './version';
87

98
export {deprecations} from './vendor/deprecations';
109
export {Deprecation, DeprecationOrId, DeprecationStatus} from './vendor/sass';
1110

12-
/**
13-
* Returns whether the given deprecation was active in the given version.
14-
*/
15-
function isActiveIn(deprecation: Deprecation, version: Version) {
16-
const deprecatedIn = deprecation.deprecatedIn;
17-
if (deprecation.status !== 'active' || !deprecatedIn) return false;
18-
if (version.major > deprecatedIn.major) return true;
19-
if (version.major < deprecatedIn.major) return false;
20-
if (version.minor > deprecatedIn.minor) return true;
21-
if (version.minor < deprecatedIn.minor) return false;
22-
return version.patch >= deprecatedIn.patch;
23-
}
24-
2511
/**
2612
* Converts a mixed array of deprecations, IDs, and versions to an array of IDs
2713
* that's ready to include in a CompileRequest.
@@ -31,9 +17,7 @@ export function getDeprecationIds(
3117
): string[] {
3218
return arr.flatMap(item => {
3319
if (item instanceof Version) {
34-
return Object.values(deprecations)
35-
.filter(deprecation => isActiveIn(deprecation, item))
36-
.map(deprecation => deprecation.id);
20+
return arr.map(item => item.toString());
3721
} else if (typeof item === 'string') {
3822
return item;
3923
}

lib/src/legacy/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import {
3232
LegacyStringOptions,
3333
Options,
3434
StringOptions,
35-
Importer,
36-
FileImporter,
3735
} from '../vendor/sass';
3836
import {wrapFunction} from './value/wrap';
3937
import {endOfLoadProtocol, LegacyImporterWrapper} from './importer';

lib/src/version.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ export class Version implements api.Version {
2121
parseInt(match[3])
2222
);
2323
}
24+
toString(): string {
25+
return `${this.major}.${this.minor}.${this.patch}`;
26+
}
2427
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sass-embedded",
33
"version": "1.77.3",
4-
"protocol-version": "2.7.0",
4+
"protocol-version": "2.7.1",
55
"compiler-version": "1.77.3",
66
"description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol",
77
"repository": "sass/embedded-host-node",

0 commit comments

Comments
 (0)