I just installed the editor Atom and the package gpp https://github.com/livace/atom-gpp to compile and run c++. When i run i get an error saying there is no such file or directory.
I think this is because of the fact that there is a whitespace in my directory path. I checked the source code of the gpp plugin and found this:
const options = (file.path + ' -o ' + compiledPath + ' ' + atom.config.get('gpp.compilerOptions')).replace(/[\s{2,}]+/g, ' ').trim();
path.join(filePath.dir, filePath.name);
const child = child_process.spawn('g++', options.split(' '), {
cwd: filePath.dir
});
I have never worked with nodeJs before, but i think that this causes the bug. Any idea how to make this work with a whitespace in the directory path (cwd)?
I found the fix. In index.js of the gpp plugin, change
const options = (file.path + ' -o ' + compiledPath + ' ' + atom.config.get('gpp.compilerOptions')).replace(/[\s{2,}]+/g, ' ').trim();
path.join(filePath.dir, filePath.name);
console.log(options.split(' '));
const child = child_process.spawn('g++', options.split(' '), {
cwd: filePath.dir
});
To
const options = atom.config.get('gpp.compilerOptions').replace(/[\s{2,}]+/g, ' ').trim();
path.join(filePath.dir, filePath.name);
var new_options = [file.path,'-o',compiledPath]
if (options != ""){
new_options = new_options.concat(options.split(' '));
}
const child = child_process.spawn('g++', new_options, {
cwd: filePath.dir
});