New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cnbritain/merlin-sass-custom-importer

Package Overview
Dependencies
Maintainers
5
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cnbritain/merlin-sass-custom-importer - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

41

lib/index.js
'use strict';
const fs = require('fs');
const path = require('path');

@@ -8,3 +9,3 @@ const chalk = require('chalk');

const LOGGER = {
'enabled': true,
'enabled': false,
'log': function(mode, ...args){

@@ -28,5 +29,6 @@ if(!this.enabled) return;

},
resolve: function(url){
resolve: function(url, previous){
const previousDir = getComponentDirFromPath(previous);
const baseUrl = url.substr(0, url.length - this.length);
return path.resolve(baseUrl, this.file);
return path.resolve(previousDir, 'node_modules', baseUrl, this.file);
}

@@ -40,5 +42,6 @@ };

},
resolve: function(url, theme){
resolve: function(url, previous, theme){
const previousDir = getComponentDirFromPath(previous);
const baseUrl = url.substr(0, url.length - this.length);
return path.resolve(baseUrl, `sass/${theme}/${theme}.scss`);
return path.resolve(previousDir, 'node_modules', baseUrl, `sass/${theme}/${theme}.scss`);
}

@@ -52,3 +55,3 @@ };

},
resolve: function(url){
resolve: function(url, previous){
let theme = null;

@@ -63,4 +66,5 @@ let len = BRAND_THEMES.length;

const previousDir = getComponentDirFromPath(previous);
const baseUrl = url.substr(0, url.length - theme.length - 1);
return path.resolve(baseUrl, `sass/${theme}/${theme}.scss`);
return path.resolve(previousDir, 'node_modules', baseUrl, `sass/${theme}/${theme}.scss`);
}

@@ -94,2 +98,3 @@ };

const realPrevious = fs.realpathSync(previous);
let sassUrl = null;

@@ -99,8 +104,7 @@

if(url.startsWith('@')){
let customUrl = path.resolve(COMPONENTS_DIR, url);
sassUrl = resolveComponentTheme(customUrl);
sassUrl = resolveComponentTheme(url, realPrevious);
// Resolve url normally, relatively
} else {
let urlParts = path.normalize(previous).split(path.sep);
let urlParts = path.normalize(realPrevious).split(path.sep);
urlParts.pop();

@@ -140,11 +144,11 @@ sassUrl = path.resolve(urlParts.join(path.sep), url);

function resolveComponentTheme(url){
function resolveComponentTheme(url, previous){
// Check if we're using our keywords - theme, wireframe. If so, resolve
// the sass location
if(WIREFRAME_KEY.contains(url)){
return WIREFRAME_KEY.resolve(url);
return WIREFRAME_KEY.resolve(url, previous);
} else if(THEME_KEY.contains(url)){
return THEME_KEY.resolve(url, merlinConfig.currentTheme);
return THEME_KEY.resolve(url, previous, merlinConfig.currentTheme);
} else if(BRAND_KEY.contains(url)){
return BRAND_KEY.resolve(url);
return BRAND_KEY.resolve(url, previous);
} else {

@@ -154,1 +158,10 @@ return url;

}
const RE_COMPONENT_DIR = new RegExp(`(.+packages${path.sep}merlin-[-\\w]+${path.sep})`);
function getComponentDirFromPath(p){
const matches = RE_COMPONENT_DIR.exec(p);
if(matches){
return matches[1];
}
throw new Error(`Cannot find component name in path: ${p}`);
}
{
"name": "@cnbritain/merlin-sass-custom-importer",
"version": "1.1.1",
"version": "1.1.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc