mirror of
https://github.com/pure-css/pure.git
synced 2024-11-07 21:34:24 +00:00
add proper module api for node users
This commit is contained in:
parent
84c18afc05
commit
cd6364faa8
19
index.js
Normal file
19
index.js
Normal file
@ -0,0 +1,19 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var cache = {};
|
||||
|
||||
module.exports = {
|
||||
getFile: function(name) {
|
||||
if (!cache[name]) {
|
||||
try {
|
||||
cache[name] = fs.readFileSync(this.getFilePath(name), 'utf-8');
|
||||
} catch(e) {
|
||||
throw new Error(name + ' does not exist');
|
||||
}
|
||||
}
|
||||
return cache[name];
|
||||
},
|
||||
getFilePath: function(name) {
|
||||
return path.resolve(__dirname, 'build', name);
|
||||
}
|
||||
};
|
@ -6,7 +6,8 @@
|
||||
"url": "git://github.com/yahoo/pure.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt test",
|
||||
"pretest": "grunt build",
|
||||
"test": "grunt test && tap test/*.js",
|
||||
"prepublish": "grunt release"
|
||||
},
|
||||
"files": "build/",
|
||||
@ -25,14 +26,16 @@
|
||||
"grunt-css-selectors": "^1.1.0",
|
||||
"grunt-postcss": "^0.8.0",
|
||||
"grunt-pure-grids": "^1.0.0",
|
||||
"grunt-stripmq": "0.0.6"
|
||||
"grunt-stripmq": "0.0.6",
|
||||
"tap": "^8.0.1"
|
||||
},
|
||||
"description": "Pure is a ridiculously tiny CSS library you can use to start any web project.",
|
||||
"bugs": {
|
||||
"url": "https://github.com/yahoo/pure/issues"
|
||||
},
|
||||
"homepage": "http://purecss.io",
|
||||
"main": "build/pure-min.css",
|
||||
"main": "index.js",
|
||||
"browser": "build/pure-min.css",
|
||||
"keywords": [
|
||||
"pure",
|
||||
"css",
|
||||
|
11
test/index.js
Normal file
11
test/index.js
Normal file
@ -0,0 +1,11 @@
|
||||
var tap = require('tap');
|
||||
var pure = require('../index.js');
|
||||
|
||||
// api
|
||||
tap.ok(pure.getFile);
|
||||
tap.ok(pure.getFilePath);
|
||||
|
||||
// assertions
|
||||
tap.match(pure.getFile('pure-min.css'), /pure\-button/, 'should load the file');
|
||||
tap.match(pure.getFilePath('pure-min.css'), /pure\-min\.css/, 'should return file path');
|
||||
tap.throws(pure.getFile, new Error('undefined does not exist'));
|
Loading…
Reference in New Issue
Block a user