Skip to content

Commit

Permalink
Supress console output when writing json
Browse files Browse the repository at this point in the history
  • Loading branch information
jhf committed Sep 11, 2019
1 parent 1ced133 commit 4b6dfb1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ts/analyser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Elm = require('./backend-elm');
function start(config: Config, project: {}) {
const reporter = Reporter.build(config.format);

dependencies.getDependencies(function(registry: Registry) {
dependencies.getDependencies(config.format == 'json' , function(registry: Registry) {
const app: ElmApp = Elm.Elm.Analyser.init({
flags: {
server: false,
Expand Down
2 changes: 1 addition & 1 deletion ts/server/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Config, ElmApp, Report } from '../domain';
const opn = require('opn');

function run(config: Config, project: {}, onload: (app: ElmApp) => void) {
dependencies.getDependencies(function(registry) {
dependencies.getDependencies(config.format == 'json', function(registry) {
const directory = process.cwd();
var Elm = require('../backend-elm.js');
var app = Elm.Elm.Analyser.init({
Expand Down
8 changes: 5 additions & 3 deletions ts/util/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ const isOutdated = function(timestamp: number): boolean {
return timestamp < barrier;
};

const getDependencies = function(cb: (jsonValue: any) => void) {
const getDependencies = function(silent : Boolean, cb: (jsonValue: any) => void) {
cache.readPackageDependencyInfo(function(err: (err: any, result: any) => void, cached: { timestamp: number; data: any }) {
if (err) {
console.log('Fetching package information from package.elm-lang.org.');
if(!silent)
console.log('Fetching package information from package.elm-lang.org.');
updatePackageDependencyInfo(cb, null);
} else {
if (isOutdated(cached.timestamp)) {
console.log('Cached package information invalidated. Fetching new data from package.elm-lang.org');
if(!silent)
console.log('Cached package information invalidated. Fetching new data from package.elm-lang.org');
updatePackageDependencyInfo(cb, cached.data);
} else {
cb(cached.data);
Expand Down

0 comments on commit 4b6dfb1

Please sign in to comment.