Sublime Forum

Multiple cmd in build system?

#1

is it possible to run multiple commands in one build system?

Among other combinations I tried to do something like this:

[code]{
“cmd”:

	{"open", "-a", "/Applications/Firefox.app"},
	{"compass", "compile", "$file_path/.."},
	{"csslint", "$file_path/../assets/css/"}
],

“selector”: “source.sass”
}[/code]

but nothing seems to work :open_mouth: the cmd array containing arrays doesn’t work either …

any ideas?

0 Likes

Is it possible to compile and execute FORTRAN in one build system?
Python build - dynamic env / multiple cmd
#2

Unfortunately, there is no support for multiple commands in a build system. I ran into this issue when working with java. Your best option is to make a bash file with the commands and have a build system that runs the bash file. I’m not a expert when it comes to build systems, so that’s as far as I can help.

Hope that points you in the right direction.

0 Likes

#3

seriously? … only one command? If its just one command in my build then why would I even need a build system :wink:

The problem with running a shell is that I can’t use the variables provided by Sublime. Mh … maybe as parameter? You guys think that works? Any experience with that?

thanks :smile:

0 Likes

#4

please feel free to support this feature :smile: sublimetext.userecho.com/topic/8 … ld-system/

0 Likes

#5

Hi,

I just found out (quite a rookie in build systems) how the command is passed to the OS. Its just a concatenation of the elements in the array, separated by spaces. This means you can enter multiple commands, with a separator that your OS understands. For instance for the windows CMD screen, its an & (or a && and only continues with the next command if the previous succeeded. See also microsoft.com/resources/docu … x?mfr=true , its for XP but worked for me in 7.)

The code below sends the line

to the windows shell.

In linux you can use the ‘;’ to separate commands.

Note: For windows you need to set shell to true for this to work. Not sure is this also needed for other OS. Below is an example for LaTex in Windows (assuming in the PATH has pdflatex, bibtex and sumatrapdf set.)

{
	"selector": "text.tex.latex",
	"working_dir":"$file_path",
	"shell":true,
	"windows":
	{
		"cmd":"pdflatex","$file_base_name","&","bibtex","$file_base_name","&","bibtex","$file_base_name","&","pdflatex","$file_base_name","&","pdflatex","$file_base_name","&","sumatrapdf", "$file_base_name.pdf"]
	}
}

So your example would be

[code]
“selector”: “source.sass”,
“shell”:true,
“windows”:
{
“cmd”:{“open”, “-a”, “/Applications/Firefox.app”,"&“compass”, “compile”, “$file_path/…”,"&",“csslint”, “$file_path/…/assets/css/”}
},

//Not sure if “linux” works
“linux”:
{
“cmd”:{“open”, “-a”, “/Applications/Firefox.app”,";“compass”, “compile”, “$file_path/…”,";",“csslint”, “$file_path/…/assets/css/”}
}[/code]

Hope this helps!

0 Likes

#6

I am trying to get ST to compile a Latex file using multiple commands: latex, dvips and ps2pdf.

On Linux I tried separating commands with “;” or “|” but only the latex command executes. Any examples of multiple command would be appreciated.

0 Likes

#7

Adding “&” with shell = true worked for me, thanks

0 Likes

#8

I believe what you want to do is to make a “make” file. Sure sublime can run a command on your behalf… but what you’ve got is multiple steps to compiling a document along with different points of failure. It’s not really in the realm of a text editor to do this. Also this would allow your project to be used by others who might not have the same setup as you do.

0 Likes