2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-22 09:57:10 +00:00
GochoMugo d4a469df6b
pkg: Fix bug #275
Bug:

  Node.js v4 does not support the ES6 syntax fully, thus we
  get the error:

    Block scoped declarations (let, const, function,class) not yet
    supported outside strict mode

Fix:

  * Load transpiled code
  * Deprecate support for Node.js v4.x

References:

  * Bug report: https://github.com/yagop/node-telegram-bot-api/issues/275
  * PR: https://github.com/yagop/node-telegram-bot-api/pull/280
  * Reported-by: @crazyabdul
  * PR-by: @crazyabdul
2017-02-08 12:16:51 +03:00

14 lines
512 B
JavaScript

/**
* If running on Nodejs 4.x and below, we load the transpiled code.
* Otherwise, we use the ES6 code.
* We are deprecating support for Node.js v4.x and below.
*/
const majorVersion = parseInt(process.versions.node.split('.')[0], 10);
if (majorVersion <= 4) {
const deprecate = require('depd')('node-telegram-bot-api');
deprecate('Node.js v4.x and below will no longer be supported in the future');
module.exports = require('./lib/telegram');
} else {
module.exports = require('./src/telegram');
}