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

elm-css

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elm-css - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

elm-css.js

117

index.js

@@ -9,26 +9,34 @@ var fs = require("fs");

module.exports = function(projectDir, stylesheetsPath, outputDir, stylesheetsModule, stylesheetsPort) {
return new Promise(function(resolve, reject) {
var originalWorkingDir = process.cwd();
var originalWorkingDir = process.cwd();
process.chdir(projectDir);
return createTmpDir()
.then(function (tmpDirPath) {
return generateCssFiles(
stylesheetsPath,
path.join(tmpDirPath, jsEmitterFilename),
outputDir,
stylesheetsModule || "Stylesheets",
stylesheetsPort || "files"
);
})
.then(function(result) {
process.chdir(originalWorkingDir);
return result;
})
.catch(function(err) {
process.chdir(originalWorkingDir);
throw Error(err);
});
}
function createTmpDir() {
return new Promise(function (resolve, reject) {
tmp.dir(function (err, tmpDirPath) {
if (err) {
return reject(err);
reject(err);
} else {
resolve(tmpDirPath);
}
process.chdir(projectDir);
return generateCssFiles(
stylesheetsPath,
path.join(tmpDirPath, jsEmitterFilename),
outputDir,
stylesheetsModule || "Stylesheets",
stylesheetsPort || "files"
)
.then(function(result) {
process.chdir(originalWorkingDir);
resolve(result);
}, function(err) {
process.chdir(originalWorkingDir);
reject(result);
});
});

@@ -39,30 +47,42 @@ });

function generateCssFiles(stylesheetsPath, emitterDest, outputDir, stylesheetsModule, stylesheetsPort) {
return new Promise(function(resolve, reject) {
return emit(stylesheetsPath, emitterDest, stylesheetsModule, stylesheetsPort)
.then(writeResults(outputDir), reject).then(resolve, reject);
});
return emit(stylesheetsPath, emitterDest, stylesheetsModule, stylesheetsPort)
.then(writeResults(outputDir));
}
function emit(src, dest, stylesheetsModule, stylesheetsPort) {
return new Promise(function(resolve, reject) {
// Compile the temporary file.
compileEmitter(src, {output: dest, yes: true}).then(function() {
return compileEmitter(src, {output: dest, yes: true})
.then(makeRequirable(dest))
.then(extractCssResults(dest, stylesheetsModule, stylesheetsPort));
}
function extractCssResults(dest, stylesheetsModule, stylesheetsPort) {
return function () {
return new Promise(function (resolve, reject) {
var Elm = require(dest);
var stylesheets = Elm.worker(Elm[stylesheetsModule]).ports[stylesheetsPort];
var failures = stylesheets.filter(function(result) {
return !result.success;
});
return failures.length > 0
? reject(reportFailures(failures))
: resolve(stylesheets);
});
};
}
function makeRequirable(dest) {
return function () {
return new Promise(function (resolve, reject) {
// Make the compiled emitter.js Node-friendly.
fs.appendFile(dest, "\nmodule.exports = Elm;", function(err) {
if (err) {
return reject(err);
reject(err);
} else {
resolve();
}
var Elm = require(dest);
var stylesheets = Elm.worker(Elm[stylesheetsModule]).ports[stylesheetsPort];
var failures = stylesheets.filter(function(result) {
return !result.success;
});
return failures.length > 0
? reject(reportFailures(failures))
: resolve(stylesheets);
});
}, reject);
});
});
}
}

@@ -73,9 +93,3 @@

return Promise.all(
results.map(function(result) {
return new Promise(function(resolve, reject) {
fs.writeFile(path.join(outputDir, result.filename), result.content + "\n", function(err, file) {
return err ? reject(err) : resolve(file);
});
})
})
results.map(writeResult(outputDir))
);

@@ -85,2 +99,13 @@ };

function writeResult(outputDir) {
return function (result) {
return new Promise(function(resolve, reject) {
fs.writeFile(path.join(outputDir, result.filename), result.content + "\n", function(err, file) {
return err ? reject(err) : resolve(result);
});
});
}
}
function reportFailures(failures) {

@@ -87,0 +112,0 @@ return "The following errors occurred during compilation:\n\n" +

{
"name": "elm-css",
"version": "0.1.1",
"version": "0.2.0",
"description": "Elm-based CSS Preprocessor",
"main": "index.js",
"bin": {
"elm-css": "./elm-css.js"
},
"directories": {

@@ -12,5 +15,2 @@ "test": "test"

},
"bin": {
"elm-css": "bin/elm-css"
},
"repository": {

@@ -34,2 +34,4 @@ "type": "git",

"dependencies": {
"chalk": "1.1.1",
"commander": "2.9.0",
"node-elm-compiler": "2.3.2",

@@ -36,0 +38,0 @@ "tmp": "0.0.28"

@@ -34,17 +34,6 @@ # elm-css [![Version](https://img.shields.io/npm/v/elm-css.svg)](https://www.npmjs.com/package/elm-css) [![Travis build Status](https://travis-ci.org/rtfeldman/elm-css.svg?branch=master)](http://travis-ci.org/rtfeldman/elm-css) [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/0j7x0mpggmtu6mms/branch/master?svg=true)](https://ci.appveyor.com/project/rtfeldman/elm-css/branch/master)

stylesheet { name = "dreamwriter" }
$ html
~ width 100 pct
~ height 100 pct
~ boxSizing borderBox
~ padding 0 px
~ margin 0 px
$ body
~ minWidth 1280 px
~ overflowX auto
~ minWidth (px 1280)
>$ div
~ width 100 pct
~ height 100 pct
. Hidden

@@ -54,10 +43,21 @@ ! display none

# Page
~ width 100 pct
~ height 100 pct
~ backgroundColor (rgb 200 128 64)
~ color (hex "CCFFFF")
~ width (pct 100)
~ height (pct 100)
~ boxSizing borderBox
~ margin 0 px
~ padding 8 px
~ padding (px 8)
~ margin zero
~ backgroundColor pageBackground
~ color pageDefaultText
$ ul . NavBar
~ margin zero
~ padding zero
>$ li
~ display inlineBlock
~ color primaryAccentColor
primaryAccentColor =
hex "ccffaa"
```

@@ -72,20 +72,7 @@

```css
html {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0px;
margin: 0px;
}
body {
overflow-x: auto;
min-width: 1280px;
overflow-x: auto;
}
body > div {
width: 100%;
height: 100%;
}
.dreamwriter_Hidden {

@@ -96,10 +83,20 @@ display: none !important;

#Page {
background-color: rgb(200, 128, 64);
color: #CCFFFF;
width: 100%;
height: 100%;
box-sizing: border-box;
margin: 0px;
padding: 8px;
background-color: rgb(100, 90, 128);
color: rgb(40, 35, 76);
margin: 0;
}
ul.dreamwriter_NavBar {
margin: 0;
padding: 0;
}
ul.dreamwriter_NavBar > li {
display: inline-block;
color: #ccffaa;
}
```

@@ -106,0 +103,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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