Skip to content

Commit

Permalink
Make launch script's Go prep compatible with Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Morfent committed May 27, 2017
1 parent 7e93177 commit 0b5d986
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pokemon-showdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if (config && config.golang) {
let stat;
let needsSrcDir = false;
try {
stat = fs.lstatSync(path.resolve(GOPATH, 'src/github.com/Zarel'));
stat = fs.lstatSync(path.resolve(GOPATH, 'src/github.com/Zarel/Pokemon-Showdown'));
} catch (e) {
needsSrcDir = true;
} finally {
Expand All @@ -67,23 +67,28 @@ if (config && config.golang) {
if (needsSrcDir) {
try {
fs.mkdirSync(path.resolve(GOPATH, 'src/github.com/Zarel'));
fs.mkdirSync(path.resolve(GOPATH, 'src/github.com/Zarel/Pokemon-Showdown'));
} catch (e) {
console.error(`Cannot make go source directory for the sockets library files! Symlink them manually from ${__dirname} to ${path.resolve(GOPATH, 'src/github.com/Zarel/Pokemon-Showdown/')}`);
process.exit(0);
}
}

try {
stat = fs.lstatSync(path.resolve(GOPATH, 'src/github.com/Zarel/Pokemon-Showdown'));
stat = fs.lstatSync(path.resolve(GOPATH, 'src/github.com/Zarel/Pokemon-Showdown/sockets'));
} catch (e) {}

if (!stat || !stat.isSymbolicLink()) {
let srcPath = path.resolve(__dirname, 'sockets');
let tarPath = path.resolve(GOPATH, 'src/github.com/Zarel/Pokemon-Showdown/sockets');
try {
// FIXME: does this even work on Windows? Check to see if `mklink /J`
// might be needed instead
fs.symlink(__dirname, path.resolve(GOPATH, 'src/github.com/Zarel/Pokemon-Showdown'));
if (process.platform === 'win32') {
child_process.execSync(`mklink /J ${tarPath} ${srcPath}`, {stdio: 'inherit'});
} else {
fs.symlink(srcPath, tarPath);
}
} catch (e) {
console.error(`Cannot make go source directory for the sockets library files! Symlink them manually from ${__dirname} to ${path.resolve(GOPATH, './src/github.com/Zarel/Pokemon-Showdown/')}`);
console.error(`Cannot make go source directory for the sockets library files! Symlink them manually from ${srcPath} to ${tarPath}`);
process.exit(0);
}
}
Expand Down

0 comments on commit 0b5d986

Please sign in to comment.