Thursday, October 24, 2019

Convert tab delimited file into comma delimited on Mac

Problem

Need to convert tab delimited file to comma delimited on Mac.

Solution

Use sed utility, note that standard version doesn't understand \t, so you can either generate tab symbol by pressing Ctrl+V and Tab or install posix sed.

sed 's/ /,/g' <source file> > <target file>

Tuesday, October 22, 2019

Simple build script that works in Windows and Linux

Problem

Have two development environments:

Laptop
MacOS, Visual Studio Professional for Mac, .NET Core 3.0

Desktop
Windows 10, Visual Studio Professional for Windows, .NET Core 3.0

Need to write a script that will be working on Windows (.bat file) and MacOS (bash). 

For example sake, scripting languages or msbuild conditions should not be used.

Solution

Never thought that it's possible, definitely not an option for complex scenarios, but for basic commands go following (assuming that script build_webpack.cmd).

echo off

goto(){
#!/bin/bash
NODE=`which node`
cd "$(dirname "$0")/.."
$NODE ./node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js $@
}

goto $@
exit

:(){
SET mypath=%~dp0
CD "%mypath:~0,-1%\\.."
node node_modules\\webpack\\bin\\webpack.js --config webpack.config.vendor.js %*

Now, if we need to invoke this script during project build, add the following line:

    <Exec Command="ClientApp/scripts/build_webpack.cmd --env.dev" />