Skip to content

Commit

Permalink
refactor: reduce the number of dependencies (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Nov 21, 2018
1 parent d6fabbc commit 5ed2304
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 48 deletions.
3 changes: 3 additions & 0 deletions bin/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
rules:
no-process-exit: off
50 changes: 38 additions & 12 deletions bin/install-winston2.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const spawn = require('child_process').spawn
/**
* Copyright 2018 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

if(fs.existsSync(path.join(__dirname,'..','test','winston-2','node_modules','winston'))){
process.exit(0)
const fs = require('fs');
const path = require('path');
const {spawn} = require('child_process');

if (
fs.existsSync(
path.join(__dirname, '..', 'test', 'winston-2', 'node_modules', 'winston')
)
) {
process.exit(0);
}

let proc;
if(process.env.npm_execpath){
proc = spawn(process.env.NODE||'node',[process.env.npm_execpath,'install'],{cwd:path.join(__dirname,'..','test','winston-2'),stdio:'inherit'})
if (process.env.npm_execpath) {
proc = spawn(
process.env.NODE || 'node',
[process.env.npm_execpath, 'install'],
{cwd: path.join(__dirname, '..', 'test', 'winston-2'), stdio: 'inherit'}
);
} else {
proc = spawn('npm',['install'],{cwd:path.join(__dirname,'..','test','winston-2'),stdio:'inherit'})
proc = spawn('npm', ['install'], {
cwd: path.join(__dirname, '..', 'test', 'winston-2'),
stdio: 'inherit',
});
}

proc.on('close',(code)=>{
process.exit(code||0)
})
proc.on('close', code => {
process.exit(code || 0);
});
27 changes: 4 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
"files": [
"build/src",
"!build/src/**/*.map",
"AUTHORS",
"CONTRIBUTORS",
"LICENSE",
"README.md",
"CODE_OF_CONDUCT.md"
],
"keywords": [
Expand All @@ -38,8 +34,7 @@
"scripts": {
"docs": "jsdoc -c .jsdoc.js",
"generate-scaffolding": "repo-tools generate all --except lib_readme",
"lint": "eslint samples/",
"prettier": "prettier --write samples/*.js samples/*/*.js",
"lint": "gts check && eslint '**/*.js'",
"presamples-test": "npm run compile",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"presystem-test": "npm run pretest",
Expand All @@ -49,34 +44,27 @@
"clean": "gts clean",
"compile": "tsc -p .",
"postcompile": "cpy ./src/types/* ./build/src/types",
"fix": "gts fix",
"fix": "gts fix && eslint --fix '**/*.js'",
"prepare": "npm run compile",
"pretest": "npm run compile && node ./bin/install-winston2.js",
"posttest": "npm run check"
},
"dependencies": {
"@google-cloud/logging": "^4.0.1",
"@sindresorhus/is": "^0.13.0",
"lodash.mapvalues": "^4.6.0",
"logform": "^1.9.1",
"logform": "^1.10.0",
"semver": "^5.5.1",
"winston-transport": "^4.2.0"
},
"devDependencies": {
"@google-cloud/common": "^0.26.0",
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"@types/glob": "^7.0.0",
"@types/is": "0.0.21",
"@types/lodash.mapvalues": "^4.6.3",
"@types/mocha": "^5.2.3",
"@types/ncp": "^2.0.1",
"@types/node": "^10.3.6",
"@types/once": "^1.4.0",
"@types/pify": "^3.0.2",
"@types/proxyquire": "^1.3.28",
"@types/rimraf": "^2.0.2",
"@types/request": "^2.48.1",
"@types/semver": "^5.5.0",
"@types/tmp": "0.0.33",
"@types/uuid": "^3.4.4",
"codecov": "^3.0.2",
"cpy-cli": "^2.0.0",
Expand All @@ -85,23 +73,16 @@
"eslint-config-prettier": "^3.0.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"glob": "^7.1.2",
"gts": "^0.9.0",
"ink-docstrap": "^1.3.2",
"intelli-espower-loader": "^1.0.1",
"jsdoc": "^3.5.5",
"mocha": "^5.2.0",
"ncp": "^2.0.0",
"once": "^1.4.0",
"pify": "^4.0.0",
"post-install-check": "0.0.1",
"prettier": "^1.13.6",
"request": "^2.88.0",
"require-inject": "^1.4.3",
"rimraf": "^2.6.2",
"source-map-support": "^0.5.6",
"teeny-request": "^3.6.0",
"tmp": "0.0.33",
"typescript": "^3.0.0",
"uuid": "^3.3.2",
"winston": "^3.1.0"
Expand Down
1 change: 1 addition & 0 deletions samples/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
rules:
no-console: off
node/no-missing-require: off
2 changes: 1 addition & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodejs-docs-samples-logging-winston",
"version": "0.0.1",
"files": ["*.js"],
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
Expand Down
4 changes: 0 additions & 4 deletions samples/system-test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
env:
mocha: true
rules:
node/no-unpublished-require: off
node/no-unsupported-features: off
no-empty: off
2 changes: 1 addition & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as util from 'util';
import * as types from './types/core';

const {Logging} = require('@google-cloud/logging');
const mapValues = require('lodash.mapvalues');
import mapValues = require('lodash.mapvalues');

type Callback = (err: Error, apiResponse: {}) => void;

Expand Down
4 changes: 1 addition & 3 deletions src/winston2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

import * as is from '@sindresorhus/is';

import {LOGGING_TRACE_KEY, LoggingCommon} from './common';
import * as types from './types/core';

Expand Down Expand Up @@ -45,7 +43,7 @@ export class LoggingWinston extends winston.Transport {

log(levelName: string, msg: string, metadata: types.Metadata,
callback: Callback) {
if (is.default.function_(metadata)) {
if (typeof metadata === 'function') {
callback = metadata as Callback;
metadata = {};
}
Expand Down
3 changes: 0 additions & 3 deletions system-test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
---
env:
mocha: true
rules:
node/no-unpublished-require: off
no-console: off
2 changes: 1 addition & 1 deletion system-test/errors-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as common from '@google-cloud/common';
import delay from 'delay';
import * as request from 'request';
import * as request from 'request'; // types only
import {teenyRequest} from 'teeny-request';

const packageJson = require('../../package.json');
Expand Down

0 comments on commit 5ed2304

Please sign in to comment.