<commit_before>'use babel';
import readPkgUp from 'read-pkg-up';
const debug = require('debug')('test-cps');
import $ from 'jquery';
export default class ClickableNpmScriptsView {

	element = null;
	button = null;
	container = null;
	constructor(serializedState) {

  }



	createElements(terminal){
		try{
			debug('creating elements');
			const path  = atom.project.getPaths()[0];
			const {pkg} = readPkgUp.sync({cwd : path});
			debug(pkg)

			if(!pkg || !pkg.scripts || Object.keys(pkg.scripts).length == 0){
				return;
			}
			 const {scripts}= pkg;
			this.container = document.createElement('div');
			this.container.classList.add('select-list');
			this.element = document.createElement('ol');
			this.element.classList.add('list-group');
			this.button = document.createElement('div');
			this.button.classList.add('inline-block');
			this.button.innerHTML = '<a>Npm scripts</a>';
			Object.keys(scripts).forEach(script=>{
				 const _el = document.createElement('li');
				 _el.innerHTML = `<a style="font-size:16px"><span style="text-transform:uppercase;font-weight:bold; color: #81C784;">${script}</span>  : <span style="font-style:italic;">${scripts[script]}</span></a>`;
				 _el.addEventListener('click',()=>{
					 if(this.modal.visible){
						 this.modal.hide();
					 }
					 try{
						 terminal.run(`npm run ${script}`);
					 }catch(err){
						 debug(err);
						 atom.notifications.addFatalError('A Fatal error occurred', {
							description : 'Please make sure platformio-atom-ide-terminal is installed and is active',<commit_msg>Bug fix at terminal run<commit_after>'use babel';
import readPkgUp from 'read-pkg-up';
const debug = require('debug')('test-cps');
import $ from 'jquery';
export default class ClickableNpmScriptsView {

	element = null;
	button = null;
	container = null;
	constructor(serializedState) {

  }



	createElements(terminal){
		try{
			debug('creating elements');
			const path  = atom.project.getPaths()[0];
			const {pkg} = readPkgUp.sync({cwd : path});
			debug(pkg)

			if(!pkg || !pkg.scripts || Object.keys(pkg.scripts).length == 0){
				return;
			}
			 const {scripts}= pkg;
			this.container = document.createElement('div');
			this.container.classList.add('select-list');
			this.element = document.createElement('ol');
			this.element.classList.add('list-group');
			this.button = document.createElement('div');
			this.button.classList.add('inline-block');
			this.button.innerHTML = '<a>Npm scripts</a>';
			Object.keys(scripts).forEach(script=>{
				 const _el = document.createElement('li');
				 _el.innerHTML = `<a style="font-size:16px"><span style="text-transform:uppercase;font-weight:bold; color: #81C784;">${script}</span>  : <span style="font-style:italic;">${scripts[script]}</span></a>`;
				 _el.addEventListener('click',()=>{
					 if(this.modal.visible){
						 this.modal.hide();
					 }
					 try{
						 terminal.run([`npm run ${script}`]);
					 }catch(err){
						 debug(err);
						 atom.notifications.addFatalError('A Fatal error occurred', {
							description : 'Please make sure platformio-atom-ide-terminal is installed and is active',
{'fraction_non_alphanumeric': 0.17327365728900257, 'fraction_numerical': 0.005754475703324808, 'mean_word_length': 4.038647342995169, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '648543', 'n_tokens_mistral': 1173, 'n_tokens_neox': 949, 'n_words': 183}