Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Commit 51a2a8c

Browse files
authored
House keeping updates (#55)
1 parent acb08a4 commit 51a2a8c

14 files changed

+10752
-1724
lines changed

.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": [
3-
"skyscanner"
3+
"@skyscanner/eslint-config-skyscanner"
44
],
55
"settings": {
66
"jest": {

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lts/erbium
1+
lts/hydrogen

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
**Breaking:**
10+
- Support Node 18, drop support for older versions.
11+
- Upgrade dependencies
12+
- `bpk-mixins` to the latest
13+
- `node-sass` to the latest
14+
- Migrate away from old `node-sass-tilde-importer` as its outdated to a local version.
15+
916
## 0.9.0
1017

1118
- Updated `bpk-mixins` to latest.

cli.js

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* backpack-node-sass
55
*
6-
* Copyright 2018-2021 Skyscanner Ltd
6+
* Copyright 2018 Skyscanner Ltd
77
*
88
* Licensed under the Apache License, Version 2.0 (the "License");
99
* you may not use this file except in compliance with the License.

importer.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* backpack-node-sass
3+
*
4+
* Copyright 2018 Skyscanner Ltd
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
const fs = require('fs');
20+
const path = require('path');
21+
22+
const findParentDir = require('find-parent-dir');
23+
24+
function resolve(targetUrl, source) {
25+
const packageRoot = findParentDir.sync(source, 'node_modules');
26+
27+
if (!packageRoot) {
28+
return null;
29+
}
30+
31+
const filePath = path.resolve(packageRoot, 'node_modules', targetUrl);
32+
const isPotentiallyDirectory = !path.extname(filePath);
33+
34+
if (isPotentiallyDirectory) {
35+
if (fs.existsSync(`${filePath}.scss`)) {
36+
return `${filePath}.scss`;
37+
}
38+
39+
if (fs.existsSync(filePath)) {
40+
return path.resolve(filePath, 'index');
41+
}
42+
}
43+
44+
if (fs.existsSync(path.dirname(filePath))) {
45+
return filePath;
46+
}
47+
48+
return resolve(targetUrl, path.dirname(packageRoot));
49+
}
50+
51+
module.exports = function importer(url, prev) {
52+
return url[0] === '~' ? { file: resolve(url.substr(1), prev) } : null;
53+
};

index.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* backpack-node-sass
33
*
4-
* Copyright 2018-2021 Skyscanner Ltd
4+
* Copyright 2018 Skyscanner Ltd
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -18,17 +18,19 @@
1818

1919
/* eslint-disable no-console */
2020

21-
const os = require('os');
22-
const fs = require('fs');
2321
const cluster = require('cluster');
22+
const fs = require('fs');
23+
const os = require('os');
2424

25-
const { argv } = require('yargs');
26-
const ora = require('ora');
27-
const sass = require('node-sass');
28-
const chunk = require('lodash/chunk');
2925
const fastGlob = require('fast-glob');
30-
const importer = require('node-sass-tilde-importer');
31-
const functions = require('bpk-mixins/sass-functions');
26+
const chunk = require('lodash/chunk');
27+
const sass = require('node-sass');
28+
const ora = require('ora');
29+
const { argv } = require('yargs');
30+
31+
const functions = require('@skyscanner/backpack-web/bpk-mixins/sass-functions');
32+
33+
const importer = require('./importer');
3234

3335
const getSassFiles = () =>
3436
fastGlob.sync(
@@ -77,7 +79,7 @@ const createWorkers = () => {
7779
spinner.start(getStatusMessage(files, successes));
7880

7981
workers.forEach((worker) => {
80-
worker.on('message', ({ error, data }) => {
82+
worker.on('message', ({ data, error }) => {
8183
if (error) {
8284
failures.push(error);
8385
} else {
@@ -117,6 +119,7 @@ const worker = () =>
117119
const promises = files.map(
118120
(file) =>
119121
new Promise((resolve, reject) =>
122+
// eslint-disable-next-line no-promise-executor-return
120123
sass.render(
121124
{
122125
file,

0 commit comments

Comments
 (0)