Skip to content

Commit

Permalink
Deprecate support for Node.js v0.12
Browse files Browse the repository at this point in the history
Notes:

  We are deprecating support for Node.js v0.12, to
  be removed in next major version!
  • Loading branch information
GochoMugo committed Jan 9, 2017
1 parent ddadc45 commit 2a782fd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ coverage/
README.hbs
output.md
output/
src/
test/
examples/
lib-doc/
Expand Down
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
module.exports = require('./src/telegram');
/**
* If running on Nodejs 0.12, we load the transpiled code.
* Otherwise, we use the ES6 code.
* We are deprecating support for Node.js v0.x
*/
const majorVersion = process.versions.node.split('.')[0];
if (majorVersion === '0') {
const deprecate = require('depd')('node-telegram-bot-api');
deprecate('Node.js v0.12 and below will no longer be supported in the future');
module.exports = require('./lib/telegram');
} else {
module.exports = require('./src/telegram');
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "node-telegram-bot-api",
"version": "0.25.0",
"description": "Telegram Bot API",
"main": "./lib/telegram.js",
"main": "./index.js",
"directories": {
"example": "examples",
"test": "test"
Expand Down
14 changes: 13 additions & 1 deletion test/telegram.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const TelegramBot = require('../lib/telegram');
const TelegramBot = require('..');
const Promise = require('bluebird');
const request = require('request-promise');
const assert = require('assert');
Expand Down Expand Up @@ -42,6 +42,18 @@ before(function beforeAll() {
});
});


describe('module.exports', function moduleExportsSuite() {
it('is loaded from src/ if NOT on Node.js 0.12', function test() {
if (process.versions.node.split('.')[0] === '0') this.skip(); // skip on Node.js v0.12
assert.equal(TelegramBot, require('../src/telegram'));
});
it('is loaded from lib/ if on Node.js 0.12', function test() {
if (process.versions.node.split('.')[0] !== '0') this.skip(); // skip on newer versions
assert.equal(TelegramBot, require('../lib/telegram'));
});
});

describe('TelegramBot', function telegramSuite() {
let bot;
let testbot;
Expand Down

0 comments on commit 2a782fd

Please sign in to comment.