How to use the chdir function from process

Find comprehensive JavaScript process.chdir code examples handpicked from public code repositorys.

23
24
25
26
27
28
29
30
31
32
    return;
}

electron.app.on('second-instance', (event, commandLine, workingDirectory) => {
    const currentDirectory = process.cwd();
    process.chdir(workingDirectory);
    const open = this._parseCommandLine(commandLine);
    process.chdir(currentDirectory);
    if (!open) {
        if (this._views.count > 0) {
fork icon91
star icon622
watch icon10

+ 3 other calls in file

28
29
30
31
32
33
34
35
36
37
  return
}

const oldDir = process.cwd()
if (fsr.fileExists(params.html.sourcePath)) {
  process.chdir(params.html.sourcePath)
}

// generate html source/output directories
fsr.ensureDirSync(htmlPath)
fork icon35
star icon68
watch icon0

52
53
54
55
56
57
58
59
60
61
62
63
async function main() {
    script_dir = fs.realpathSync(__dirname);
    root_dir = fs.realpathSync(script_dir + '/../../..');


    // All the code assumes we are working from the script directory
    process.chdir(script_dir);


    let command = test;
    let patterns = [];

fork icon7
star icon35
watch icon0

6
7
8
9
10
11
12
13
14
15
16
17
18


function cd(path) {
  console.log(`$ cd ${path}`);


  if (!DRY_RUN) {
    chdir(path);
  }
}


function mkdir(path) {
fork icon2
star icon3
watch icon0

10
11
12
13
14
15
16
17
18
19
20
21
22
23
    res.status(200).json({'branches': [branches]});
});




const getBranches = () => {
    process.chdir('../../bizom-next');


    const branches = command.execSync('git branch').toString().split('\n');


    let remoteBranches = [];
fork icon0
star icon0
watch icon1

148
149
150
151
152
153
154
155
156
157
  );
}

console.log("[devtools-node-test-runner] Found test suite: " + suite);
const testPath = path.join(__dirname, SUITES[suite].path);
chdir(testPath);

console.log("[devtools-node-test-runner] Check `yarn` is available");
try {
  // This will throw if yarn is unavailable
fork icon0
star icon0
watch icon0

8
9
10
11
12
13
14
15
16
17
18


console.log('current working directory: ', process.cwd())
try {
 
  // Change the directory
  process.chdir('./data');
  console.log('directory changed to: ', process.cwd())
} catch (err) {
     
  // Printing error if occurs
fork icon0
star icon0
watch icon0