From 0b12484dc9c100d76908a0c927b34374cbaec534 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 25 Dec 2015 13:46:35 +0100 Subject: Add --cd-datadir setting --- NEWS | 4 ++++ yarn | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index e01387b..56e3bcf 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,10 @@ Version 0.19, released UNRELEASED This can be used to use Python instead of sh: `--shell=/usr/bin/python2 --shell-arg=''`. +* Yarn now supports the `--cd-datadir` setting to have each step run + in `DATADIR` instead of `SRCDIR`. The default remains `SRCDIR`, but + at some point in the future, the default will probably change. + Version 0.18, released 2015-11-06 --------------------------------- diff --git a/yarn b/yarn index c6e32cc..0782a8f 100755 --- a/yarn +++ b/yarn @@ -100,6 +100,11 @@ class YarnRunner(cliapp.Application): metavar='ARG', default=['-xeu']) + self.settings.boolean( + ['cd-datadir'], + 'change to DATADIR when running commands', + default=False) + def stdout(self, msg): self.output.write(msg) self.output.flush() @@ -448,6 +453,11 @@ class YarnRunner(cliapp.Application): for i, match in enumerate(m.groups('')): env['MATCH_%d' % (i+1)] = match + if self.settings['cd-datadir']: + cwd = datadir + else: + cwd = '.' + fd, shell_script = tempfile.mkstemp() os.close(fd) with open(shell_script, 'w') as f: @@ -460,7 +470,7 @@ class YarnRunner(cliapp.Application): logging.warning('shell_args: %r', shell_args) logging.warning('shell_script: %r', shell_script) exit, stdout, stderr = cliapp.runcmd_unchecked( - [shell] + shell_args + [shell_script], env=env) + [shell] + shell_args + [shell_script], env=env, cwd=cwd) os.remove(shell_script) logging.debug('Exit code: %d' % exit) -- cgit v1.2.1