Skip to content

Commit

Permalink
House keeping updates (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
olliecurtis committed Oct 19, 2023
1 parent acb08a4 commit 51a2a8c
Show file tree
Hide file tree
Showing 14 changed files with 10,752 additions and 1,724 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": [
"skyscanner"
"@skyscanner/eslint-config-skyscanner"
],
"settings": {
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/erbium
lts/hydrogen
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

**Breaking:**
- Support Node 18, drop support for older versions.
- Upgrade dependencies
- `bpk-mixins` to the latest
- `node-sass` to the latest
- Migrate away from old `node-sass-tilde-importer` as its outdated to a local version.

## 0.9.0

- Updated `bpk-mixins` to latest.
Expand Down
2 changes: 1 addition & 1 deletion cli.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* backpack-node-sass
*
* Copyright 2018-2021 Skyscanner Ltd
* Copyright 2018 Skyscanner Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
53 changes: 53 additions & 0 deletions importer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* backpack-node-sass
*
* Copyright 2018 Skyscanner Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const fs = require('fs');
const path = require('path');

const findParentDir = require('find-parent-dir');

function resolve(targetUrl, source) {
const packageRoot = findParentDir.sync(source, 'node_modules');

if (!packageRoot) {
return null;
}

const filePath = path.resolve(packageRoot, 'node_modules', targetUrl);
const isPotentiallyDirectory = !path.extname(filePath);

if (isPotentiallyDirectory) {
if (fs.existsSync(`${filePath}.scss`)) {
return `${filePath}.scss`;
}

if (fs.existsSync(filePath)) {
return path.resolve(filePath, 'index');
}
}

if (fs.existsSync(path.dirname(filePath))) {
return filePath;
}

return resolve(targetUrl, path.dirname(packageRoot));
}

module.exports = function importer(url, prev) {
return url[0] === '~' ? { file: resolve(url.substr(1), prev) } : null;
};
23 changes: 13 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* backpack-node-sass
*
* Copyright 2018-2021 Skyscanner Ltd
* Copyright 2018 Skyscanner Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,17 +18,19 @@

/* eslint-disable no-console */

const os = require('os');
const fs = require('fs');
const cluster = require('cluster');
const fs = require('fs');
const os = require('os');

const { argv } = require('yargs');
const ora = require('ora');
const sass = require('node-sass');
const chunk = require('lodash/chunk');
const fastGlob = require('fast-glob');
const importer = require('node-sass-tilde-importer');
const functions = require('bpk-mixins/sass-functions');
const chunk = require('lodash/chunk');
const sass = require('node-sass');
const ora = require('ora');
const { argv } = require('yargs');

const functions = require('@skyscanner/backpack-web/bpk-mixins/sass-functions');

const importer = require('./importer');

const getSassFiles = () =>
fastGlob.sync(
Expand Down Expand Up @@ -77,7 +79,7 @@ const createWorkers = () => {
spinner.start(getStatusMessage(files, successes));

workers.forEach((worker) => {
worker.on('message', ({ error, data }) => {
worker.on('message', ({ data, error }) => {
if (error) {
failures.push(error);
} else {
Expand Down Expand Up @@ -117,6 +119,7 @@ const worker = () =>
const promises = files.map(
(file) =>
new Promise((resolve, reject) =>
// eslint-disable-next-line no-promise-executor-return
sass.render(
{
file,
Expand Down

0 comments on commit 51a2a8c

Please sign in to comment.