Skip to content

Instantly share code, notes, and snippets.

View yousifalraheem's full-sized avatar
👾
Debugging

Yousif Al-Raheem yousifalraheem

👾
Debugging
View GitHub Profile
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-1.json
Last active June 14, 2020 07:31
NPM auto generated package
{
"name": "test-project",
"version": "1.0.0",
"description": "Project description",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-2.json
Created June 14, 2020 07:32
NPM package necessary information
{
"repository": {
"type": "git",
"url": "https://provider.com/path/to/repo"
},
"bugs": {
"url": "https://provider.com/path/to/repo/issues"
},
"homepage": "https://deployurl.com/"
}
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-3.json
Created June 14, 2020 07:33
NPM Package script with chained spread commands
{
"scripts": {
"build": "rimraf dist && tslint -p tsconfig.json && webpack -mode production"
}
}
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-4.json
Created June 14, 2020 07:34
NPM commands moved to individual scripts
{
"scripts": {
"clean": "rimraf dist",
"lint": "tslint -p tsconfig.json",
"build:prod": "webpack -mode production",
"build": "npm run clean && npm run lint && npm run build:prod"
}
}
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-5.json
Created June 14, 2020 07:35
More complicated example of clean chained scripts
{
"scripts": {
"clean:dist": "rimraf dist",
"clean:test": "rimraf converage",
"clean": "npm run clean:dist && npm run clean:test",
"lint": "tslint -p tsconfig.json",
"build:prod": "webpack - mode production",
"test": "jest",
"deploy": "gh-pages -d dist",
"build": "npm run clean && npm run lint && npm test && npm run build:prod && npm run deploy"
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-6.json
Last active June 14, 2020 08:38
NPM Package scripts cleaned up using pre and post hooks
{
"scripts": {
"lint": "tslint -p tsconfig.json",
"pretest": "rimraf converage",
"test": "jest",
"prebuild:prod": "npm run lint && npm test",
"build:prod": "webpack - mode production",
"prebuild": "rimraf dist",
"build": "npm run build:prod",
"postbuild": "npm run deploy",
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-7.json
Created June 14, 2020 07:37
NPM Package long script with URL
{
"scripts": {
"generate": "openapi-generator -i http://loooooong-url-to-your-application-swagger-url/v2/swagger.json -g typescript-axios"
}
}
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-8.json
Created June 14, 2020 07:38
NPM Package script with cleaned up script using npm package variables
{
"config": {
"swaggerUrl": "http://loooooong-url-to-your-application-swagger-url/v2/swagger.json"
},
"scripts": {
"generate": "openapi-generator -i $npm_package_config_swaggerUrl -g typescript-axios"
}
}
@yousifalraheem
yousifalraheem / Medium-ecf2cfb0a3f8-9.json
Created June 14, 2020 07:40
NPM Package script with cleaned up script using npm package variables for both Linux and Windows
{
"config": {
"swaggerUrl": "http://loooooong-url-to-your-application-swagger-url/v2/swagger.json"
},
"scripts": {
"generate": "openapi-generator -i $npm_package_config_swaggerUrl -g typescript-axios",
"generate:win": "openapi-generator -i %npm_package_config_swaggerUrl% -g typescript-axios"
}
}
@yousifalraheem
yousifalraheem / browser-detect.js
Last active September 8, 2020 10:11
Detect browser in use with JavaScript
function whichBrowser() {
if (isFirefox()) {
return "Firefox";
} else if (isEdge()) {
return "Edge";
} else if (isIE()) {
return "Internet Explorer";
} else if (isOpera()) {
return "Opera";
} else if (isVivaldi()) {