Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/convert to ts #998

Merged
merged 2 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/api-token.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MissingApiTokenError } from '../lib/errors';

import * as config from './config';
import * as userConfig from './user-config';
import { config as userConfig } from './user-config';

export function api() {
// note: config.TOKEN will potentially come via the environment
Expand Down
2 changes: 1 addition & 1 deletion src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as snykConfig from 'snyk-config';
import * as userConfig from './user-config';
import { config as userConfig } from './user-config';
import * as url from 'url';

const DEFAULT_TIMEOUT = 5 * 60; // in seconds
Expand Down
2 changes: 1 addition & 1 deletion src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ snyk.isolate = {
};

// this is the user config, and not the internal config
snyk.config = require('./user-config');
snyk.config = require('./user-config').config;
12 changes: 8 additions & 4 deletions src/lib/sub-process.js → src/lib/sub-process.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const childProcess = require('child_process');
import * as childProcess from 'child_process';

module.exports.execute = function(command, args, options) {
const spawnOptions = { shell: true };
export function execute(
command: string,
args: string[],
options?: { cwd: string },
): Promise<string> {
const spawnOptions: childProcess.SpawnOptions = { shell: true };
if (options && options.cwd) {
spawnOptions.cwd = options.cwd;
}
Expand All @@ -25,4 +29,4 @@ module.exports.execute = function(command, args, options) {
resolve(stdout || stderr);
});
});
};
}
4 changes: 1 addition & 3 deletions src/lib/user-config.js → src/lib/user-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const Configstore = require('@snyk/configstore');
const pkg = require(__dirname + '/../../package.json');
const config = new Configstore(pkg.name);

module.exports = config;
export const config = new Configstore(pkg.name);
2 changes: 1 addition & 1 deletion test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as cli from '../../../src/cli/commands';
import { fakeServer } from '../fake-server';
import * as subProcess from '../../../src/lib/sub-process';
import { getVersion } from '../../../src/lib/version';
import * as userConfig from '../../../src/lib/user-config';
import { config as userConfig } from '../../../src/lib/user-config';
import { chdirWorkspaces, getWorkspaceJSON } from '../workspace-helper';
import * as _ from 'lodash';

Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/cli-protect.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from 'tap';
import { exec } from 'child_process';
import * as userConfig from '../../src/lib/user-config';
import { config as userConfig } from '../../src/lib/user-config';
import { sep } from 'path';
import * as tap from 'tap';
import * as path from 'path';
Expand Down