Skip to content

Commit

Permalink
chore(release): 2.0.0 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Aug 27, 2018
1 parent 26a64bd commit 771c43a
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
language: node_js

cache:
directories:
- "node_modules"

node_js:
- "6"
- "8"
- "10"
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function createGenerator(pattern, options) {
options = options || {};
var context = options && typeof options.context === 'string'
? options.context
: '';
: process.cwd();
var hashPrefix = options && typeof options.hashPrefix === 'string'
? options.hashPrefix
: '';
Expand All @@ -30,6 +30,7 @@ module.exports = function createGenerator(pattern, options) {
var loaderContext = {
resourcePath: filepath
};

var loaderOptions = {
content: util.format('%s%s+%s',
hashPrefix,
Expand Down
297 changes: 297 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generic-names",
"version": "1.0.2",
"version": "2.0.0",
"description": "Helper for building generic names, similar to webpack",
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -26,6 +26,6 @@
"tape": "^4.6.2"
},
"dependencies": {
"loader-utils": "^0.2.16"
"loader-utils": "^1.1.0"
}
}
11 changes: 6 additions & 5 deletions test/cssspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const genericNames = require('../index');
const test = require('tape');
const path = require('path');

// According to the CSS spec, identifiers cannot
// start with a digit, two hyphens, or a hyphen
Expand All @@ -12,34 +13,34 @@ const test = require('tape');
test('identity', t => {
const generate = genericNames('[local]');

t.equal(generate('foo', '/test/case/source.css'), 'foo');
t.equal(generate('foo', path.join(__dirname, 'test/case/source.css')), 'foo');
t.end();
});

test('leading digit', t => {
const generate = genericNames('0[local]');

t.equal(generate('foo', '/test/case/source.css'), '_0foo');
t.equal(generate('foo', path.join(__dirname, 'test/case/source.css')), '_0foo');
t.end();
});

test('leading digit in the token', t => {
const generate = genericNames('[local]');

t.equal(generate('0foo', '/test/case/source.css'), '_0foo');
t.equal(generate('0foo', path.join(__dirname, 'test/case/source.css')), '_0foo');
t.end();
});

test('leading two hyphens', t => {
const generate = genericNames('--[local]');

t.equal(generate('foo', '/test/case/source.css'), '_--foo');
t.equal(generate('foo', path.join(__dirname, 'test/case/source.css')), '_--foo');
t.end();
});

test('leading hyphen and digit', t => {
const generate = genericNames('-0[local]');

t.equal(generate('foo', '/test/case/source.css'), '_-0foo');
t.equal(generate('foo', path.join(__dirname, 'test/case/source.css')), '_-0foo');
t.end();
});
Loading

0 comments on commit 771c43a

Please sign in to comment.