Skip to content

Commit

Permalink
fix: don't use reserved keywords
Browse files Browse the repository at this point in the history
closes #834
  • Loading branch information
fent committed Dec 18, 2020
1 parent 39df066 commit fa2f47b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
@@ -1,7 +1,10 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017
"ecmaVersion": 2017,
"ecmaFeatures": {
"impliedStrict": true
}
},
"env": {
"es6": true,
Expand Down
6 changes: 3 additions & 3 deletions lib/utils.js
Expand Up @@ -140,16 +140,16 @@ exports.deprecate = (obj, prop, value, oldPath, newPath) => {


// Check for updates.
const package = require('../package.json');
const pkg = require('../package.json');
exports.lastUpdateCheck = 0;
exports.checkForUpdates = () => {
if (!process.env.YTDL_NO_UPDATE && !package.version.startsWith('0.0.0-') &&
if (!process.env.YTDL_NO_UPDATE && !pkg.version.startsWith('0.0.0-') &&
Date.now() - exports.lastUpdateCheck >= 1000 * 60 * 60 * 12) {
exports.lastUpdateCheck = Date.now();
return miniget('https://api.github.com/repos/fent/node-ytdl-core/releases/latest', {
headers: { 'User-Agent': 'ytdl-core' },
}).text().then(response => {
if (JSON.parse(response).tag_name !== `v${package.version}`) {
if (JSON.parse(response).tag_name !== `v${pkg.version}`) {
console.warn('\x1b[33mWARNING:\x1B[0m ytdl-core is out of date! Update with "npm install ytdl-core@latest".');
}
});
Expand Down
10 changes: 5 additions & 5 deletions test/utils-test.js
Expand Up @@ -106,11 +106,11 @@ describe('utils.checkForUpdates', () => {

describe('Already on latest', () => {
it('Does not warn the console', async() => {
const package = require('../package.json');
sinon.replace(package, 'version', 'v1.0.0');
const pkg = require('../package.json');
sinon.replace(pkg, 'version', 'v1.0.0');
const scope = nock('https://api.github.com')
.get('/repos/fent/node-ytdl-core/releases/latest')
.reply(200, { tag_name: `v${package.version}` });
.reply(200, { tag_name: `v${pkg.version}` });
const warnSpy = sinon.spy();
sinon.replace(console, 'warn', warnSpy);
sinon.replace(Date, 'now', sinon.stub().returns(Infinity));
Expand All @@ -122,8 +122,8 @@ describe('utils.checkForUpdates', () => {

describe('When there is a new update', () => {
it('Warns the console about the update', async() => {
const package = require('../package.json');
sinon.replace(package, 'version', 'v1.0.0');
const pkg = require('../package.json');
sinon.replace(pkg, 'version', 'v1.0.0');
const scope = nock('https://api.github.com')
.get('/repos/fent/node-ytdl-core/releases/latest')
.reply(200, { tag_name: 'vInfinity.0.0' });
Expand Down

0 comments on commit fa2f47b

Please sign in to comment.