1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Allow npm to install to a directory that doesn't yet exist

If path is specified but does not exist, create it.
Fail if path is specified but is not a directory
This commit is contained in:
willthames 2014-03-21 13:26:07 +10:00
parent 14499e8bf3
commit 7272877df6

View file

@ -139,6 +139,10 @@ class Npm(object):
#If path is specified, cd into that path and run the command.
cwd = None
if self.path:
if not os.path.exists(self.path):
os.makedirs(self.path)
if not os.path.isdir(self.path):
self.module.fail_json(msg="path %s is not a directory" % self.path)
cwd = self.path
rc, out, err = self.module.run_command(cmd, check_rc=check_rc, cwd=cwd)