def run()

in aws_lambda_builders/workflows/ruby_bundler/bundler.py [0:0]


    def run(self, args, cwd=None):
        if not isinstance(args, list):
            raise ValueError("args must be a list")

        if not args:
            raise ValueError("requires at least one arg")

        invoke_bundler = [self.bundler_exe] + args

        LOG.debug("executing Bundler: %s", invoke_bundler)

        p = self.osutils.popen(invoke_bundler, stdout=self.osutils.pipe, stderr=self.osutils.pipe, cwd=cwd)

        out, _ = p.communicate()

        if p.returncode != 0:
            if p.returncode == GEMFILE_NOT_FOUND:
                LOG.warning("Gemfile not found. Continuing the build without dependencies.")

                # Clean up '.bundle' dir that gets generated before the build fails
                check_dir = self.osutils.get_bundle_dir(cwd)
                if self.osutils.directory_exists(check_dir):
                    self.osutils.remove_directory(check_dir)
            else:
                # Bundler has relevant information in stdout, not stderr.
                raise BundlerExecutionError(message=out.decode("utf8").strip())

        return out.decode("utf8").strip()