From c07ac96cc1acf66cc69da3ead38364b51b6df836 Mon Sep 17 00:00:00 2001 From: Sam Richard Date: Sat, 16 Sep 2017 09:16:08 -0400 Subject: [PATCH] Add support for Eyeglass Resolves https://github.com/necolas/normalize.css/issues/638 --- .gitignore | 1 + eyeglass-exports.js | 7 +++++++ package.json | 15 +++++++++++++-- to-sass.js | 21 +++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 eyeglass-exports.js create mode 100644 to-sass.js diff --git a/.gitignore b/.gitignore index 3c3629e64..480602687 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +_normalize.scss diff --git a/eyeglass-exports.js b/eyeglass-exports.js new file mode 100644 index 000000000..dfbb2fd77 --- /dev/null +++ b/eyeglass-exports.js @@ -0,0 +1,7 @@ +var path = require('path'); + +module.exports = function(eyeglass, sass) { + return { + sassDir: path.join(__dirname) + } +} diff --git a/package.json b/package.json index 2c2d77056..0238863b4 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,26 @@ "style": "normalize.css", "files": [ "LICENSE.md", - "normalize.css" + "normalize.css", + "eyeglass-exports.js", + "to-sass.js" ], + "eyeglass": { + "needs": "^1.0.0", + "exports": "eyeglass-exports.js", + "name": "normalize" + }, "devDependencies": { "stylelint": "^7.9.0", "stylelint-config-standard": "^16.0.0" }, "scripts": { - "test": "stylelint normalize.css" + "test": "stylelint normalize.css", + "postinstall": "node ./to-sass.js" }, + "keywords": [ + "eyeglass-module" + ], "repository": "necolas/normalize.css", "license": "MIT", "bugs": "https://github.com/necolas/normalize.css/issues", diff --git a/to-sass.js b/to-sass.js new file mode 100644 index 000000000..85f051b49 --- /dev/null +++ b/to-sass.js @@ -0,0 +1,21 @@ +'use strict'; + +var fs = require('fs'); +var path = require('path'); + +const pkg = require('./package.json'); + +// Output file paths +var input = path.join(__dirname, pkg.main); +var output = path.join(__dirname, '_' + path.basename(pkg.main, '.css') + '.scss'); + +// Clean up Sass file if it's already there +try { + fs.statSync(output); + fs.unlink(output); +} catch(e) { + // It's OK if this errors, it means the file doesn't exist +} + +// Cpoy input file to output file +fs.writeFileSync(output, fs.readFileSync(input));