Skip to content

Instantly share code, notes, and snippets.

@hasenbalg
Created February 20, 2018 13:50
Show Gist options
  • Save hasenbalg/fe979c840708c729a445fb2470273bd8 to your computer and use it in GitHub Desktop.
Save hasenbalg/fe979c840708c729a445fb2470273bd8 to your computer and use it in GitHub Desktop.
Install typescript on an old cruton ubuntu for chrome book and sets up example project
function makeIndexHtml {
FILE="index.html";
touch $FILE;
cat >$FILE <<EOL
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>New TypeScript Project</title>
</head>
<body>
</body>
<script type="text/javascript" src="js/main.js"></script>
</html>
EOL
echo "write $FILE"
}
function makeTsconfigjson {
FILE="tsconfig.json";
touch $FILE;
cat >$FILE <<EOL
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
}
}
EOL
echo "write $FILE"
}
function makeExampleTs {
FILE="main.ts";
touch $FILE;
cat >$FILE <<EOL
class Test{
private _name: string;
constructor(){
}
get name(){
return _name;
}
set name(newName:name){
this._name = newName;
}
}
let test = new Test();
test.name = 'huhu';
EOL
}
if which node > /dev/null
then
echo "node is installed, skipping..."
else
echo "node installing"
sudo apt update
sudo apt install nodejs npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install typeScript -g
fi
cd ~/
DIRECTORY="$(pwd)/typescriptTest1";
DIRECTORYJS="$DIRECTORY/js";
if [ -d "$DIRECTORY" ]; then
echo "$DIRECTORY exists";
else
echo "no";
mkdir "$DIRECTORY";
cd $DIRECTORY;
makeIndexHtml;
makeTsconfigjson;
mkdir "$DIRECTORYJS";
cd $DIRECTORYJS;
makeExampleTs;
fi
cd $DIRECTORYJS
tsc --watch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment