[code] [textadept] run command in the project dir?

From: basiliscos <basiliscos.att.openmailbox.org>
Date: Wed, 2 Dec 2015 17:09:56 +0300


Usually in perl projects there is "t" directory, which will contain
tests. It might contain sub-directories, etc.

The usual way to run the test is:

prove -l -v t/my-case/file.t

(from project root).

I have tried the following:

textadept.run.run_commands['t'] = function()
   local root = io.get_project_root()
   if (root) then
      local cmd = 'cd "' .. root .. '"; prove -l %p'
      return cmd

,but it complains, that "cd command not found".

To solve the issue the function should return not only the actual
command to execute, but also the working directory, i.e.

instead of:
if type(command) == 'function' then command = command() end

should be
if type(command) == 'function' then
  local new_command, new_working_dir = command()
  command = new_command
  if (new_working_dir) then cwd = new_working_dir end

Then the run_command customization would look like:
textadept.run.run_commands['t'] = function()
   local root = io.get_project_root()
   if (root) then
      return 'prove -l %p', root

(I'll find out how to convert absolute file path to
relative-to-project-root later)

Best regards,
Bασιλίσκος Arcticus ὑπέρnihilisticus 
(aka Ivan Baidakou) <basiliscos.att.openmailbox.org>
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Wed 02 Dec 2015 - 09:09:56 EST

This archive was generated by hypermail 2.2.0 : Thu 03 Dec 2015 - 06:50:44 EST