Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sheetify

Package Overview
Dependencies
Maintainers
3
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sheetify - npm Package Compare versions

Comparing version 5.0.5 to 5.1.0

35

index.js

@@ -8,4 +8,9 @@ const cssPrefix = require('postcss-prefix')

const xtend = require('xtend')
const stackTrace = require('stack-trace')
const cssResolve = require('style-resolve').sync
const fs = require('fs')
const path = require('path')
module.exports = sheetify
module.exports.getPrefix = getPrefix

@@ -16,13 +21,23 @@ // transform css

// handle tagged template calls directly from Node
if (Array.isArray(src)) src = src.join('')
const isTemplate = Array.isArray(src)
if (isTemplate) src = src.join('')
assert.equal(typeof src, 'string', 'src must be a string')
src = src.trim()
const prefix = '_' + crypto.createHash('md5')
.update(src)
.digest('hex')
.slice(0, 8)
// Ensure prefix is always correct when run from inside node
var css
if (!isTemplate && (!filename || typeof filename === 'object')) {
// module or file name via tagged template call w or w/out options
const callerDirname = path.dirname(stackTrace.get()[1].getFileName())
const resolved = cssResolve(src, { basedir: callerDirname })
css = fs.readFileSync(resolved, 'utf8')
} else {
// it better be some css
css = src
}
const prefix = getPrefix(css)
// only parse if in a browserify transform
if (filename) parseCss(src, filename, prefix, options, done)
if (typeof filename === 'string') parseCss(src, filename, prefix, options, done)

@@ -32,2 +47,10 @@ return prefix

function getPrefix (css) {
const prefix = '_' + crypto.createHash('md5')
.update(css.trim())
.digest('hex')
.slice(0, 8)
return prefix
}
// parse css

@@ -34,0 +57,0 @@ // (str, str, str, obj, fn) -> null

13

package.json
{
"name": "sheetify",
"version": "5.0.5",
"version": "5.1.0",
"description": "Modular CSS bundler",

@@ -25,3 +25,3 @@ "repository": "stackcss/sheetify",

"falafel": "^1.2.0",
"insert-css": "^0.2.0",
"insert-css": "^1.0.0",
"is-stream": "^1.0.1",

@@ -32,2 +32,3 @@ "map-limit": "0.0.1",

"resolve": "^1.1.7",
"stack-trace": "0.0.9",
"static-eval": "^0.2.4",

@@ -39,11 +40,13 @@ "style-resolve": "^1.0.0",

"peerDependencies": {
"insert-css": "^0.2.0"
"insert-css": "^1.0.0"
},
"devDependencies": {
"browserify": "^13.0.0",
"codecov.io": "^0.1.6",
"concat-stream": "^1.5.1",
"css-extract": "^1.0.0",
"css-extract": "^1.1.2",
"css-type-base": "^1.0.2",
"css-wipe": "^4.2.2",
"dependency-check": "^2.5.1",
"insert-css": "^0.2.0",
"insert-css": "^1.0.0",
"istanbul": "^0.3.19",

@@ -50,0 +53,0 @@ "jsdom": "^8.0.2",

require('./prefix')
require('./import')
require('./plugins')
require('./json')

@@ -7,2 +7,3 @@ const browserify = require('browserify')

const vm = require('vm')
const cssResolve = require('style-resolve').sync

@@ -15,6 +16,23 @@ const transform = require('../transform')

t.plan(1)
const prefix = sheetify('.foo { color: blue; }')
t.equal(prefix, '_d1b3f246', 'prefix is equal')
const prefix = sheetify`.foo { color: blue; }`
const expected = sheetify.getPrefix('.foo { color: blue; }')
t.equal(prefix, expected, 'prefix is equal')
})
t.test('should return a prefix with relative path in Node', function (t) {
t.plan(1)
const expath = path.join(__dirname, 'fixtures/prefix-import-source.css')
const expected = sheetify.getPrefix(fs.readFileSync(expath, 'utf8'))
const prefix = sheetify('./fixtures/prefix-import-source.css')
t.equal(prefix, expected, 'prefix is equal')
})
t.test('should return a prefix with a module name in Node', function (t) {
t.plan(1)
const expath = cssResolve('css-wipe')
const expected = sheetify.getPrefix(fs.readFileSync(expath, 'utf8'))
const prefix = sheetify('css-wipe')
t.equal(prefix, expected, 'prefix is equal')
})
t.test('should prefix and inline template strings', function (t) {

@@ -81,3 +99,3 @@ t.plan(3)

function log (msg) {
t.equal(msg, '_c284eb7d', 'echoes prefix')
t.equal(msg, '_0081131d', 'echoes prefix')
}

@@ -84,0 +102,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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