Skip to content

Commit

Permalink
use yarn if called from yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorfr committed Jul 8, 2018
1 parent 327bb58 commit 53c61a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions dist/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ var child_process_1 = require("child_process");
var tasks_1 = require("./tasks");
var npmInstall = function (project) {
return function (done) {
var child = child_process_1.exec('npm install', {
var isYarn = path.basename(process.env.npm_execpath || "npm").startsWith("yarn");
var installer = isYarn ? 'yarn' : 'npm';
var child = child_process_1.exec(isYarn ? 'yarn' : 'npm install', {
cwd: project.directory
}, function (error, stdout, stderr) {
if (error) {
console.error('execution error:', error);
done(error);
return;
}
console.log("npm install done for " + project.name);
console.log(installer + " install done for " + project.name);
if (stdout) {
console.log(stdout);
}
Expand Down
7 changes: 5 additions & 2 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import { ITask, getTasks } from './tasks';

var npmInstall = (project: ITask) => {
return (done: Function) => {
const isYarn = path.basename(process.env.npm_execpath || "npm").startsWith("yarn")

var child = exec('npm install', {
var installer = isYarn ? 'yarn' : 'npm';

var child = exec(isYarn ? 'yarn' : 'npm install', {
cwd: project.directory
}, (error, stdout, stderr) => {
if (error) {
Expand All @@ -16,7 +19,7 @@ var npmInstall = (project: ITask) => {
return;
}

console.log(`npm install done for ${project.name}`);
console.log(`${installer} install done for ${project.name}`);

if (stdout) {
console.log(stdout);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation: */
"lib": ["es2015"], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
Expand Down

0 comments on commit 53c61a6

Please sign in to comment.