Sets the working directory.

@param null|string $workingDirectory The working directory.

@return ProcessBuilder

@throws InvalidArgumentException When the working directory is non null and does not exist.
500409
public function setWorkingDirectory($workingDirectory)
    {
        if ((null !== $workingDirectory) && !is_dir($workingDirectory)) {
            throw new InvalidArgumentException('The working directory must exist.');
        }

        $this->workingDirectory = $workingDirectory;

        return $this;
    }
1113242
function(config) {
    var directory = null;

    if(config.workingDir) {
       directory = path.join(config.workingDir, 'level'); 
    } else {
        throw Errors.invalidConfig('Invalid configuration. Working directory not defined.');
    }
    
    return directory;
}
144524
public static function app($workingDir, $file) {
        $workingFile = rtrim($workingDir, '/').'/'.ltrim($file, '/');
        return self::file($workingFile, true, true);
    }
276510
public function setOutputDirectory(PhingFile $outputDirectory)
    {
        try {
            if (!$outputDirectory->exists()) {
                $this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(), Project::MSG_VERBOSE);
                if (!$outputDirectory->mkdirs()) {
                    throw new IOException("Unable to create Output directory: " . $outputDirectory->getAbsolutePath());
                }
            }
            $this->outputDirectory = $outputDirectory->getCanonicalPath();
        } catch (IOException $ioe) {
            throw new BuildException($ioe);
        }
    }
937381
public function setCurrentDirectory($directory)
    {
        $directory = $this->normalizePath("$this->baseDir/$directory");

        $this->checkIfPathInBaseDir($directory);

        $this->currentDir = $directory;

        return $this;
    }
383127
private function checkDirectories($inputDir, $outputDir)
    {
        if (!is_dir($inputDir)) {
            throw new InvalidArgumentException(sprintf("Unable to find input directory: %s", $inputDir));
        }

        if (!is_dir($outputDir)) {
            // Try to create output directory
            if (mkdir($outputDir) === false) {
                throw new RuntimeException(sprintf("Unable to create output directory: %s", $outputDir));
            }
        }
    }
386823
public function setCacheDir($cacheDir)
    {
        if ($cacheDir !== null) {
            if (!is_dir($cacheDir)) {
                throw new Exception\InvalidArgumentException(
                    "Cache directory '{$cacheDir}' not found or not a directory"
                );
            } elseif (!is_writable($cacheDir)) {
                throw new Exception\InvalidArgumentException(
                    "Cache directory '{$cacheDir}' not writable"
                );
            } elseif (!is_readable($cacheDir)) {
                throw new Exception\InvalidArgumentException(
                    "Cache directory '{$cacheDir}' not readable"
                );
            }

            $cacheDir = rtrim(realpath($cacheDir), DIRECTORY_SEPARATOR);
        } else {
            $cacheDir = sys_get_temp_dir();
        }

        $this->cacheDir = $cacheDir;

        return $this;
    }
932022
public function setDirectory($directory = __DIR__)
    {
        if (!is_dir($directory)) {
            $message = "Directory {$directory} doesn't exist.";
            throw new \RuntimeException($message);
        }
        $this->directory = $directory;
        $this->gitattributesFile = $directory
            . DIRECTORY_SEPARATOR
            . '.gitattributes';

        return $this;
    }
354036
private function setPaths($baseDirectory)
    {
        $this->setOption('ROOT', rtrim($baseDirectory, '/') . '/');
        $this->setOption('CORE', dirname(dirname(dirname(__DIR__))) . '/');
        $this->setOption('PUBLIC', self::ROOT() . 'public/');
        $this->setOption('TEMPLATES', self::ROOT() . 'templates/');
        $this->setOption('MODULES', self::ROOT() . 'modules/');
        $this->setOption('PLUGINS', self::ROOT() . 'plugins/');
        $this->setOption('COMPONENTS', self::ROOT() . 'components/');
    }
151687
@VisibleForTesting
    Process execute() {
        File workingDirectory = program.workingDirectory();
        if (!InvalidWorkingDirectoryException.check(workingDirectory)) {
            throw new InvalidWorkingDirectoryException(workingDirectory);
        }
        final Process process = createProcess(getCommandLine());
        processTracker.add(process);
        return process;
    }
382247
public function setProjectDirectory(string $dir): Application
    {
        if (is_dir($dir)) {
            $this->projectDir = $dir;
        }

        return $this;
    }
645211
@Override
	public void setWorkingDirectory(String workingDir) {
		this.workingDir = workingDir;
		if (!this.workingDir.endsWith(URL_SEPARATOR)) {
			this.workingDir = this.workingDir + URL_SEPARATOR;
		}
	}
160831
public function setLogDirectory(?string $path): self
    {
        if (null !== $path) {
            if (!is_dir($path)) {
                throw new InvalidArgumentException(sprintf(
                    "Tracy log path '%s' does`t exists",
                    $path
                ));
            }

            $path = realpath($path);
        }

        $this->logDirectory = $path;
        return $this;
    }
922588
public function setDir($dir)
    {
        if (in_array($dir, Direction::asArray(), true) === true) {
            $this->dir = $dir;
        } else {
            $msg = "The 'dir' argument must be a value from the Direction enumeration.";
            throw new InvalidArgumentException($msg);
        }
    }
419027
private function updateLockerInWorkingDirectory(Console\Output\OutputInterface $output, string $workingDirectory): int
    {
        return $this->getApplication()->run(
            new Console\Input\ArrayInput([
                'command' => 'update',
                '--lock' => true,
                '--no-autoloader' => true,
                '--no-plugins' => true,
                '--no-scripts' => true,
                '--no-suggest' => true,
                '--working-dir' => $workingDirectory,
            ]),
            $output
        );
    }
1120959
public function setGitDir($dir, $check = true)
    {
        if (!is_string($dir)) {
            throw new InvalidArgumentException('string', 0);
        }

        if ($check && !realpath($dir)) {
            throw new Exception("Directory $dir does not exist");
        }
        $this->gitDir = $dir;
        $this->command->chdir($dir);
        return $this;
    }
1140106
public function findParentByFile($fileName, $directory = null)
    {
        if (empty($fileName)) {
            throw new InvalidArgumentException('$fileName (value was ' . $fileName . ') must be set.', 1525785151);
        }

        $directory = $directory ?? getcwd();
        $hit = null;

        while ($directory !== $this->environment->getRootDirectory()
            && $directory !== ''
            && $directory !== '.'
            && $directory !== '/'
        ) {
            if ($this->filesystem->exists($directory . '/' . $fileName)) {
                $hit = $directory;
                break;
            }
            $directory = dirname($directory);
        }

        return $hit;
    }