Github Desktop commit not working with husky prehook - github-desktop

I installed husky and set up a prehook, which works in the CLI. However, when I try to commit in the Github desktop, the "committing to..." button is loading forever. For context, .git file is located one level higher than package.json.
package.json
"scripts": {
...
"prepare": "cd .. && husky install dashboard/.husky"
}
pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
cd dashboard
npm run test
I tried adding PATH="/usr/local/bin:$PATH" to pre-commit but it doesn't seem to help.

I figured it out thanks to this comment here:
https://github.com/desktop/desktop/issues/2518#issuecomment-323872966
Basically, my hook was running npm run test, and the test had --watch option so it never exited. Removing the command fixed the issue.

Related

Jenkins on ec2 not recognizing composer or npm - both are installed

I've installed Jenkins on an Amazon ec2 instance according to the instructions here https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos and when I try to run a job that has an execute shell command step that does "composer install" or "npm install" it isn't recognizing either command. However from the terminal (as ec2-user) I can run both. Is there something I need to do to let Jenkins know where to find these commands?
I just realized I can sudo su jenkins and install composer as that user.
For NPM, this article helped. You need to install the nodejs plugin, restart Jenkins, then in the build environment section of the configuration of your job, choose "Provide Node & npm bin/ folder to PATH".
I was still having problems running ng commands - after installing the ng client as the jenkins user. This post helped - which says to add "npm run" before ng.
I hope this helps someone. Especially since I figured it out moments after offering my bounty!

Jenkins Slave (service) , cannot detect protractor

We are using slave as service and we r trying to run protractor with simple batch file after calling to npm install , but from some reason protractor was not detected, do u know what could be the reason/problem?
if i use web option (slave) for running job - everything went fine,
BTW - I try to set the service with user that allowed to run the test, and also set node in PATH, but nothing help
Appreciate your comments,
Thanks
Eyal
because you install protractor as a global package, So you should use webdriver-manager from global package install folder. The current folder where you execute npm install -g protractor has no webdriver-manager this cmd/binary. So jenkins report can't find webdriver-manager in current folder or PATH.
For best practice, you should add protractor as your nodejs project's dependency through npm install -S protractor before you write script, after do that, you will found 'protractor' will be add into package.json.
When others who get your source code, he only need to execute npm install under folder where package.json insides to get all dependencies installed.
After npm install done, the webdriver-manager will be found <package.json file inside folder>\node_modules\.bin\webriver-manager
So your cmd should write down as following:
pwd
ls -l "${WORKSPACE}"
cd /d <package.json file inside folder>
npm install
node_modules\.bin\webdriver-manager update
node_modules\.bin\protractor conf.js

Thingsboard UI Customization

I would love to be able to customize the UI to fit the guidelines of our brand.
I'm not very familiar with Sass and Angular.
Can you suggest which IDE, tools or plugins are best in this particular project to modify and test the UI without having to build the whole project every time?
Thank you!
thingsboard ui is using angularjs, react, webpack, babel and ...
but all of the ui is connected to all project and i couldn't run it separate and after npm install and npm run build had some problems . based on pom.xml file in ui folder the project first is build with maven and make a jar file in ui folder then run it as front-end module . if we want not to clean install maven every time we change the project, one way is to run commands in pom.xml file ourselves . because the project does not use our global installed npm and node first it installs the particular version of them (nodeVersion: v6.9.1 npmVersion: 3.10.8) locally in ui folder then move them to folder named node and make link to node_modules : ln -s node_modules/npm/bin/npm-cli.js npm after this run the commands:
node/npm install
node/npm run build
node/npm start
so you can write a script file to run all this commands together . don't forget to change your tb-gateway forwardHost and forwardPort in server.js file . the script file based on my os :
#!/usr/bin/env bash
if [ ! -d node-v6.9.1-linux-x64 ] ; then
wget https://nodejs.org/dist/v6.9.1/node-v6.9.1-linux-x64.tar.gz
tar -xzvf node-v6.9.1-linux-x64.tar.gz
mkdir node
mv node-v6.9.1-linux-x64/lib/node_modules node/
mv node-v6.9.1-linux-x64/bin/* node/
cd node
ln -s node_modules/npm/bin/npm-cli.js npm
cd ..
fi
node/npm install
node/npm run build
node/npm start
after all this every ui project build will take time . you can use webstorm IDE or some web ides to open ui folder .

Why doesn't postinstall run every time?

I have a package.json file that has the following JSON at the bottom.
"scripts": {
"postinstall": [
"./node_modules/bower/bin/bower install && ./node_modules/protractor/bin/webdriver-manager update"
]
}
My reason for having this is so bower dependencies and my protractor tests will run after an "npm install". However, it seems that "postinstall" doesn't always run. I'm trying to get everything setup on Jenkins, so I'd like to be able to run the following commands and be good to go.
npm install
grunt jenkins
The jenkins task calls tasks to build, test, and run e2e tests.
I was able to fix this by changing the command from an array to a string.
"scripts": {
"postinstall": "./node_modules/bower/bin/bower install && ./node_modules/protractor/bin/webdriver-manager update"
}

new grunt task added to Jenkins is not found

I am running Jenkins on Windows and grunt v0.4.1. I added a new task grunt-replace to the grunt.js however jenkins is having an issue seeing it:
C:\Jenkins\workspace\xxx>grunt
Local Npm module "grunt-replace" not found. Is it installed?
I've tried several things...
npm install -g grunt-replace
Restarting the jenkins service
npm install grunt-replace
I have installed these as the service jenkins is running under..
What am i missing here? What is the correct way to get jenkins to see the new task?
whats the way you start your task? i would add grunt-replace to the devDependencies in your package.json , add your test-command to the scripts.test-property in your package.json, and then let jenkins execute that.
package.json
{
...some other configs
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"grunt-replace": "*",
... all the grunt-modules you need to be installed
}
}
jenkins excute
$ npm install && npm test

Resources