Skip to content

Commit d7dbc84

Browse files
authored
Merge pull request #335 from peterramsing/add-node-warning
Add node warning for v0.10 and v0.12
2 parents ecdf969 + 7b288d5 commit d7dbc84

File tree

6 files changed

+66
-2
lines changed

6 files changed

+66
-2
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
test/*.js
2+
lib/check-node-version.js

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ node_js:
66
- iojs
77
- "0.12"
88
- "0.10"
9+
- "5"
10+
- "6"
11+
- "7"
912

1013
after_success:
1114
- npm run coveralls

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you have any questions, comments, or concerns please feel free to [open an is
1818

1919
Lost makes use of [`calc()`](https://webdesign.tutsplus.com/tutorials/calc-grids-are-the-best-grids--cms-22902) to create stunning grids based on fractions you define without having to pass a lot of options.
2020

21-
21+
Note: After LostGrid version 8 I'm no longer going to be ensuring it works on Node 0.10 and 0.12. It still might and I will be open when it breaks but I'll be following the [Node LTS plan for Node](https://github.com/nodejs/LTS#lts-schedule). Let me know if you any questions. Thanks!
2222

2323

2424
## Table of Contents
@@ -778,6 +778,8 @@ div {
778778
- Safari 9+
779779
- Automated browser testing with Selenium is coming soon. 👍
780780

781+
Note: After LostGrid version 8 I'm no longer going to be ensuring it works on Node 0.10 and 0.12. It still might and I will be open when it breaks but I'll be following the [Node LTS plan for Node](https://github.com/nodejs/LTS#lts-schedule). Let me know if you any questions. Thanks!
782+
781783
**[:arrow_up: back to top](#table-of-contents)**
782784

783785
 

lib/check-node-version.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var warning = 'LostGrid is dropping support for Node versions 0.10 and 0.12 after version 8.\n If you need to retain your use of Node v0.10 v0.12 it\'s recommended you don\'t\n update without testing it first. Submit an issue if you have questions. \n\n lostgrid.org';
2+
3+
module.exports = function checkNodeVersion(nodeVersion) {
4+
var returnOutput = {
5+
warn: false,
6+
warning: warning
7+
}
8+
if (nodeVersion) {
9+
nodeVersion = nodeVersion.split('.')[0];
10+
if (nodeVersion < 1) {
11+
returnOutput.warn = true;
12+
}
13+
}
14+
return returnOutput;
15+
};

lost.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ var lostOffset = require('./lib/lost-offset');
1414
var lostMove = require('./lib/lost-move');
1515
var lostMasonryWrap = require('./lib/lost-masonry-wrap');
1616
var lostMasonryColumn = require('./lib/lost-masonry-column');
17+
var checkNodeVersion = require('./lib/check-node-version');
18+
19+
// Get the version of Node
20+
var nodeVersion = process.env.npm_config_node_version;
1721

1822
// Lost At Rules and Declarations
1923
var libs = [
@@ -41,9 +45,13 @@ var defaultSettings = {
4145
module.exports = postcss.plugin('lost', function lost(settings) {
4246
var theseSettings = assign({}, defaultSettings, settings || {});
4347

48+
if (checkNodeVersion(nodeVersion).warn === true) {
49+
console.log(checkNodeVersion(nodeVersion).warning);
50+
}
51+
4452
return function executeLostGrid(css) {
4553
libs.forEach(function executeEachLostRule(lib) {
46-
lib(css, theseSettings);
54+
lib(css, theseSettings, nodeVersion);
4755
});
4856
};
4957
});

test/node-version.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
var expect = require('chai').expect;
4+
var checkNodeVersion = require('../lib/check-node-version');
5+
var nodeVersion = process.env.npm_config_node_version;
6+
7+
describe('Logs Node warning if node version is 0.x', function() {
8+
describe('Operates as it should with hard coded versions', function() {
9+
it('logs on 0.12 and 0.10', function() {
10+
expect(checkNodeVersion('0.10').warn).to.equal(true);
11+
expect(checkNodeVersion('0.10').warn).to.not.equal(false);
12+
expect(checkNodeVersion('0.12').warn).to.equal(true);
13+
expect(checkNodeVersion('0.12').warn).to.not.equal(false);
14+
});
15+
it('doesn\'t log on new versions', function() {
16+
expect(checkNodeVersion('6.9.1').warn).to.equal(false);
17+
expect(checkNodeVersion('6.9.1').warn).to.not.equal(true);
18+
expect(checkNodeVersion('7.0.0').warn).to.equal(false);
19+
expect(checkNodeVersion('7.0.0').warn).to.not.equal(true);
20+
});
21+
});
22+
describe('Operates as it should with \"real\" Node version', function() {
23+
it('logs on 0.12 and 0.10', function() {
24+
if (nodeVersion.split('.')[0] < 1) {
25+
console.log('Does log');
26+
expect(checkNodeVersion(nodeVersion).warn).to.equal(true);
27+
expect(checkNodeVersion(nodeVersion).warn).to.not.equal(false);
28+
} else {
29+
console.log('Doesn\'t log');
30+
expect(checkNodeVersion(nodeVersion).warn).to.equal(false);
31+
expect(checkNodeVersion(nodeVersion).warn).to.not.equal(true);
32+
}
33+
});
34+
});
35+
});

0 commit comments

Comments
 (0)