Socket
Socket
Sign inDemoInstall

gts

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gts - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

2

build/src/cli.d.ts

@@ -13,2 +13,2 @@ export interface Logger {

}
export declare type VerbFunction = (options: Options, fix?: boolean) => Promise<boolean>;
export declare type VerbFilesFunction = (options: Options, files: string[], fix?: boolean) => Promise<boolean>;

@@ -44,3 +44,3 @@ #!/usr/bin/env node

var logger = console;
var cli = meow("\n\tUsage\n\t $ gts <verb> [options]\n\n Verb can be:\n init Adds default npm scripts to your package.json.\n check Checks code for formatting and lint issues.\n fix Fixes formatting and linting issues (if possible).\n clean Removes all files generated by the build.\n\n Options\n --help Prints this help message.\n -y, --yes Assume a yes answer for every prompt.\n --dry-run Don't make any acutal changes.\n\n\tExamples\n $ gts init -y\n $ gts check\n $ gts fix\n $ gts clean\n");
var cli = meow("\n\tUsage\n\t $ gts <verb> [<file>...] [options]\n\n Verb can be:\n init Adds default npm scripts to your package.json.\n check Checks code for formatting and lint issues.\n fix Fixes formatting and linting issues (if possible).\n clean Removes all files generated by the build.\n\n Options\n --help Prints this help message.\n -y, --yes Assume a yes answer for every prompt.\n --dry-run Don't make any acutal changes.\n\n\tExamples\n $ gts init -y\n $ gts check\n $ gts fix\n $ gts fix src/file1.ts src/file2.ts\n $ gts clean\n");
function usage(msg) {

@@ -52,3 +52,3 @@ if (msg) {

}
function run(verb) {
function run(verb, files) {
return __awaiter(this, void 0, void 0, function () {

@@ -79,7 +79,7 @@ var options, lint, format, _a, _b, _c;

return [3 /*break*/, 13];
case 3: return [4 /*yield*/, lint(options)];
case 3: return [4 /*yield*/, lint(options, files)];
case 4:
_b = (_d.sent());
if (!_b) return [3 /*break*/, 6];
return [4 /*yield*/, format(options)];
return [4 /*yield*/, format(options, files)];
case 5:

@@ -89,7 +89,7 @@ _b = (_d.sent());

case 6: return [2 /*return*/, (_b)];
case 7: return [4 /*yield*/, lint(options, true)];
case 7: return [4 /*yield*/, lint(options, files, true)];
case 8:
_c = (_d.sent());
if (!_c) return [3 /*break*/, 10];
return [4 /*yield*/, format(options, true)];
return [4 /*yield*/, format(options, files, true)];
case 9:

@@ -109,6 +109,6 @@ _c = (_d.sent());

updateNotifier({ pkg: cli.pkg }).notify();
if (cli.input.length !== 1) {
if (cli.input.length < 1) {
usage();
}
run(cli.input[0]).then(function (success) {
run(cli.input[0], cli.input.slice(1)).then(function (success) {
if (!success) {

@@ -115,0 +115,0 @@ process.exit(1);

@@ -21,3 +21,4 @@ /**

* @param fix whether to automatically fix the format
* @param files files to format
*/
export declare function format(options: Options, fix?: boolean): Promise<boolean>;
export declare function format(options: Options, files?: string[], fix?: boolean): Promise<boolean>;

@@ -10,9 +10,13 @@ "use strict";

* @param fix whether to automatically fix the format
* @param files files to format
*/
function format(options, fix) {
function format(options, files, fix) {
if (files === void 0) { files = []; }
if (fix === void 0) { fix = false; }
var program = lint_1.createProgram(options);
var srcFiles = program.getSourceFiles()
.map(function (sourceFile) { return sourceFile.fileName; })
.filter(function (f) { return !f.endsWith('.d.ts'); });
var srcFiles = files.length > 0 ?
files :
program.getSourceFiles()
.map(function (sourceFile) { return sourceFile.fileName; })
.filter(function (f) { return !f.endsWith('.d.ts'); });
return fix ? fixFormat(srcFiles) : checkFormat(srcFiles);

@@ -19,0 +23,0 @@ }

@@ -58,5 +58,2 @@ "use strict";

var util_1 = require("./util");
function noop() {
/* empty */
}
function query(message, question, defaultVal, options) {

@@ -269,3 +266,3 @@ return __awaiter(this, void 0, void 0, function () {

_a.trys.push([0, 2, , 8]);
return [4 /*yield*/, util_1.readJsonp('./package.json', noop, true /*strict*/)];
return [4 /*yield*/, util_1.readJsonp('./package.json')];
case 1:

@@ -291,3 +288,3 @@ packageJson = _a.sent();

cp.spawnSync('npm', ['init', '-y']);
return [4 /*yield*/, util_1.readJsonp('./package.json', noop, true /* strict */)];
return [4 /*yield*/, util_1.readJsonp('./package.json')];
case 5:

@@ -294,0 +291,0 @@ packageJson = _a.sent();

@@ -5,6 +5,7 @@ import * as ts from 'typescript';

* Run tslint with the default configuration. Returns true on success.
* @param options gts options
* @param files files to run linter on
* @param fix automatically fix linter errors
* @param options gts options
*/
export declare function lint(options: Options, fix?: boolean): boolean;
export declare function lint(options: Options, files?: string[], fix?: boolean): boolean;
export declare function createProgram(options: Options): ts.Program;

@@ -22,6 +22,8 @@ "use strict";

* Run tslint with the default configuration. Returns true on success.
* @param options gts options
* @param files files to run linter on
* @param fix automatically fix linter errors
* @param options gts options
*/
function lint(options, fix) {
function lint(options, files, fix) {
if (files === void 0) { files = []; }
if (fix === void 0) { fix = false; }

@@ -32,4 +34,4 @@ var tslintConfigPath = path.join(options.gtsRootDir, 'tslint.json');

var linter = new tslint_1.Linter({ fix: fix, formatter: 'codeFrame' }, program);
var files = tslint_1.Linter.getFileNames(program);
files.forEach(function (file) {
var srcFiles = files.length > 0 ? files : tslint_1.Linter.getFileNames(program);
srcFiles.forEach(function (file) {
var fileContents = program.getSourceFile(file).getFullText();

@@ -36,0 +38,0 @@ linter.lint(file, fileContents, configuration);

export declare const readFilep: (...args: any[]) => Promise<any>;
export declare const readJsonp: any;
export declare const rimrafp: (...args: any[]) => Promise<any>;
export declare const writeFileAtomicp: any;
export declare function readJsonp(jsonPath: string): Promise<any>;
export interface ReadFileP {

@@ -6,0 +6,0 @@ (path: string, encoding: string): Promise<any>;

@@ -58,5 +58,18 @@ "use strict";

exports.readFilep = pify(fs.readFile);
exports.readJsonp = pify(require('read-package-json'));
exports.rimrafp = pify(rimraf);
exports.writeFileAtomicp = pify(require('write-file-atomic'));
function readJsonp(jsonPath) {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_b = (_a = JSON).parse;
return [4 /*yield*/, exports.readFilep(jsonPath)];
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
}
});
});
}
exports.readJsonp = readJsonp;
function nop() {

@@ -63,0 +76,0 @@ /* empty */

{
"name": "gts",
"version": "0.3.1",
"version": "0.4.0",
"description": "Google TypeScript Style",

@@ -24,2 +24,3 @@ "repository": "google/ts-style",

"clean": "rm -rf ./build/",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
"compile": "tsc -p .",

@@ -31,3 +32,3 @@ "format-check": "./bin/format-check.sh",

"prepare": "npm run compile",
"test": "npm run compile && ava build/test/test*.js",
"test": "npm run compile && nyc ava build/test/test*.js",
"posttest": "npm run lint && npm run format-check"

@@ -47,3 +48,2 @@ },

"pify": "^3.0.0",
"read-package-json": "^2.0.10",
"rimraf": "^2.6.1",

@@ -62,3 +62,3 @@ "tslint": "^5.5.0",

"@types/node": "^8.0.17",
"@types/pify": "0.0.28",
"@types/pify": "3.0.0",
"@types/rimraf": "2.0.2",

@@ -68,5 +68,7 @@ "@types/tmp": "0.0.33",

"ava": "^0.22.0",
"codecov": "^2.3.0",
"make-dir": "^1.0.0",
"ncp": "^2.0.0",
"source-map-support": "^0.4.15",
"nyc": "^11.2.1",
"source-map-support": "^0.5.0",
"tmp": "0.0.31",

@@ -73,0 +75,0 @@ "typescript": "^2.4.1"

@@ -8,2 +8,3 @@ # gts - Google TypeScript style

[![Known Vulnerabilities][snyk-image]][snyk-url]
[![codecov][codecov-image]][codecov-url]

@@ -41,11 +42,13 @@ > ***NOTE: This repo is a work-in-progress and is not ready for general use just yet. This is not an official Google product.***

[codecov-image]: https://codecov.io/gh/google/ts-style/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/google/ts-style
[david-dev-image]: https://david-dm.org/google/ts-style/dev-status.svg
[david-dev-url]: https://david-dm.org/google/ts-style?type=dev
[david-image]: https://david-dm.org/google/ts-style.svg
[david-url]: https://david-dm.org/google/ts-style
[npm-image]: https://img.shields.io/npm/v/gts.svg
[npm-url]: https://npmjs.org/package/gts
[snyk-image]: https://snyk.io/test/github/google/ts-style/badge.svg
[snyk-url]: https://snyk.io/test/github/google/ts-style
[travis-image]: https://travis-ci.org/google/ts-style.svg?branch=master
[travis-url]: https://travis-ci.org/google/ts-style
[david-image]: https://david-dm.org/google/ts-style.svg
[david-url]: https://david-dm.org/google/ts-style
[david-dev-image]: https://david-dm.org/google/ts-style/dev-status.svg
[david-dev-url]: https://david-dm.org/google/ts-style?type=dev
[snyk-image]: https://snyk.io/test/github/google/ts-style/badge.svg
[snyk-url]: https://snyk.io/test/github/google/ts-style

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc