Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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);
}
};
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand All @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -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'));