Skip to content
This repository has been archived by the owner on Jun 25, 2023. It is now read-only.

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
nzws committed Feb 18, 2020
1 parent 5b31614 commit 67b6f57
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
17 changes: 10 additions & 7 deletions bin/symlink-necessary-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const findYarnWorkspaceRoot = require('find-yarn-workspace-root');
const fs = require('fs');
const mkdirp = require('mkdirp');
const path = require('path');
const spawnSync = require('../common/cross-spawn-sync');
const sudo = require('sudo-prompt');

/**
* Creates symlinks for packages that some programs expect to be under the project's node_modules
Expand Down Expand Up @@ -53,7 +53,7 @@ function symlinkNecessaryPackage(projectPath, packageName) {
debug(`Creating symlink from %s to %s`, path.join(scopePath, name), relativePackagePath);
fs.symlinkSync(relativePackagePath, path.join(scopePath, name));
} else {
let relativePackagePath = path.resolve('', '../../', packageName);
let relativePackagePath = path.resolve(process.env.INIT_CWD, 'node_modules', packageName);
//let relativePackagePath = path.relative(nodeModulesPath, workspacePackagePath);
console.log(relativePackagePath);

Expand All @@ -69,11 +69,14 @@ function symlinkNecessaryPackage(projectPath, packageName) {
fs.symlinkSync(relativePackagePath, path.join(nodeModulesPath, packageName));
} catch (_) {
// for windows
const result = spawnSync('mklink', ['/d', path.join(nodeModulesPath, packageName), relativePackagePath]);

if (result.error) {
console.error(result.error);
}
sudo.exec(`mklink /d ${path.join(nodeModulesPath, packageName)} ${relativePackagePath}`, {
name: 'dotplants expo yarn workspaces'
},
function(error, stdout) {
if (error) throw error;
console.log('stdout: ' + stdout);
}
);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"dependencies": {
"debug": "^4.1.1",
"find-yarn-workspace-root": "^1.2.0",
"mkdirp": "^0.5.1"
"mkdirp": "^0.5.1",
"sudo-prompt": "^9.1.1"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,11 @@ strip-json-comments@^3.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7"
integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==

sudo-prompt@^9.1.1:
version "9.1.1"
resolved "https://registry.yarnpkg.com/sudo-prompt/-/sudo-prompt-9.1.1.tgz#73853d729770392caec029e2470db9c221754db0"
integrity sha512-es33J1g2HjMpyAhz8lOR+ICmXXAqTuKbuXuUWLhOLew20oN9oUCgCJx615U/v7aioZg7IX5lIh9x34vwneu4pA==

supports-color@^5.3.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
Expand Down

0 comments on commit 67b6f57

Please sign in to comment.