How to enable type checking for rules that require type checking on the command line? - tslint

Some rules require type checking. I don't understand from the documentation about type checking what to do to run it on the command line.
If I run somethink like
tslint --project admin/tslint.json "project/**/*.ts{,x}"
I get the error message
Invalid source file: project/main.ts. Ensure that the
files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.
The documentation says
When using the CLI, the --project flag will automatically create a
program from the specified tsconfig.json file and enable rules that
require the type checker.
But I don't see the program generated by tslint nor do I understand how to run it.
So, what are the steps to run tslint with type checking form the command line?

The --project argument needs the typescript compiler tsc configuration file (typically tsconfig.json).
The --config argument gets the tslint configuration (typically tslint.json):
So, the full command line is:
tslint --config tslint.json --project tsconfig.json
You don't have to specify the files on the command line -- they are found in the tsconfig.json file...

Related

Cannot execute golang executable after building

I have to preface that I am beginner when it comes to using Go. I have cloned a project that can be found at https://gitlab.com/gitlab-org/security-products/analyzers/common.git
Before building, the environment variables for go are GOARCH=amd64 GOOS=linux.
After cloning the project I navigate to into the directory that has go files, that is command/, and run the following command go build -o analyzer
This outputs a file called analyzer. The one I noticed is that I can't execute this file unless I do chmod +x analyzer.
When I do execute the that binary I get an error
./analyzer: line 1: syntax error near unexpected token `newline'
./analyzer: line 1: `!<arch>'
That package is not a main package. Only main packages (with the package main statement) will build into executable files.

CMake substitute text in a file generated by a target

I have cmake target which runs a setup.exe on windows which installs a tool using add_custom_target as follows
# TOOL_TEMP_INSTALL_PATH is the installation path which is set earlier in cmake
add_custom_target(
install_tool
COMMAND ${TOOL_TEMP_DIR}/setup.exe /DIR=${TOOL_TEMP_INSTALL_PATH}
)
After the installation, I want to replace text in a configuration file located at ${TOOL_TEMP_INSTALL_PATH}/tool.ini replacing a line of text "LICENSE_FILE=Enter License server" with "LICENSE_FILE=30309#server"
Following commands will achieve this but this needs to be run after install_tool target is built.
file(READ "${TOOL_TEMP_INSTALL_PATH}/tool.ini" filedata)
string(REGEX REPLACE "LICENSE_FILE=Enter License server here"
"LICENSE_FILE=30309#server" filedata "${filedata}")
file(WRITE "${TOOL_TEMP_INSTALL_PATH}/tool.ini" "${filedata}")
How can I add these commands as a dependency to install_tool? Or is there a better way to achieve this on windows?
Since you want to run two things in order as part of the same target, you can use multiple COMMAND entries in the same target. The difficulty is that COMMAND can't handle CMake code, but only system commands. The typical solution is to call CMake in a subshell on a script file:
COMMAND ${CMAKE_COMMAND} -P path_to_script
So, place your file modification commands in a file in your source tree called license-install.cmake, and add another COMMAND to your add_custom_target
Hint: You might consider add_custom_command instead, so you can specify a file in the installed tree as a dependency. This will allow CMake to see the installed tool as a build product, and to skip the install step if the tool is already installed. You'll still need an add_custom_target with a dependency on your command output to hook it in correctly.

How can I see the internal compile commands which fail in a "go get" installation?

I am pulling and installing a package with dependencies, and a compilation fails, in this case not finding a file, magic.h. How do I see what the compilation commands and flags were? The -v option does not help. (I do NOT want ideas about where to get magic.h from, this is just an example.)
$ go get -u github.com/presbrey/magicmime
# github.com/presbrey/magicmime
../../../src/github.com/presbrey/magicmime/magicmime.go:20:11: fatal error: 'magic.h' file not found
#include <magic.h>
How can I find, for example, where it was looking for include files, what source exactly it was compiling? (In this case the source file I see in $GO_PATH/src has that #include commented out, and a /usr/local/include/match.h exists anyway.)
Run go build -x on problem package:
go build -x github.com/presbrey/magicmime

Error when compiling multiple typescript files

I am trying to compile multiple typescript files on a Windows machine from the command prompt (using this procedure).
I have created a file ts.txt with the following content:
--module amd
-target ES5
dir *.ts /b /s
I then run the following command:
tsc #ts.txt
Then I get the following errors:
error TS5007: Cannot resolve referenced file: 'dir'.
error TS5007: Cannot resolve referenced file: '*.ts'.
error TS5007: Cannot resolve referenced file: '/b'.
error TS5007: Cannot resolve referenced file: '/s'.
If I move the two typescript options to the command line instead of having them in the file, i still get the same error. What am I doing wrong?
I am using typescript 1.0.1.0.
It appears that the # parameter is for TypeScript command line options, not Windows CMD line options. I couldn't find a nice concise option of what it actually accepts but I'm gussing it takes the file names from a list and the other tsc options appended. Such as '*.ts --noImplicitAny'.
I changed the file ts.txt to;
--module amd
-target ES5
*.ts
and it works, make sure you have .ts files in the wildcard path otherwise it will still bork.

Integrate sass on macOS and Jenkins

I have installed sass on my mac build agent. Attach the approve: here is output from my machine
ep#ep2:~$ sass -v
Sass 3.3.8 (Maptastic Maple)
ep#ep2:~$ sass --help
Usage: sass [options] [INPUT] [OUTPUT]
Description:
Converts SCSS or Sass files to CSS.
Options:
-s, --stdin Read input from standard input instead of an input file
--trace Show a full traceback on error
--unix-newlines Use Unix-style newlines in written files.
--scss Use the CSS-superset SCSS syntax.
--watch Watch files or directories for changes.
The location of the generated CSS can be set using a colon:
sass --watch input.sass:output.css
sass --watch input-dir:output-dir
--update Compile files or directories to CSS.
Locations are set like --watch.
And write it to bash_profile:
Users/ep/.rvm/bin:~/.gem/ruby/1.8/bin
When i try to execute my job in jenkins it failed with
14:18:34 /bin/sh -c sass\ -f\ -C\ ${INPUT_FILE_PATH}\ ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.css
14:18:34 /bin/sh: sass: command not found
14:18:34 Command /bin/sh failed with exit code 127
I made a little investigation and have added this property to jenkins nodes propey and checked the user, the user run script it's the same from whom i installed gem.
How to fix it?
Probably the tool sass is not in the shell PATH when Jenkins executes your build script.
You should either:
run the tool by providing the full path to it or
modify the PATH environment variable to include the installation directory of the tool.
Please note that modifying PATH by changing shell initialization file is often the wrong way to do it with Jenkins. When Jenkins executes a shell, it is not an interactive login shell and those often skip initialization files like .profile or .bashrc or bash_profile. The details can be found in your shell man page.
It is better to add the PATH to Jenkins configuration, either to master configuration (if the job executes on master) or slave configuration (if the job executes on a slave). In the configuration check the box titled "Environment variables" and add name and value for required environment variables.
It might not be a bad idea to begin build scripts with command env which prints all environments variables. Often it makes debugging problems like this a lot easier.

Resources