copy-package
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -12,3 +12,2 @@ 'use strict'; | ||
var fs__default = _interopDefault(fs); | ||
var process$1 = _interopDefault(require('process')); | ||
var findWorkspaceRoot = _interopDefault(require('find-yarn-workspace-root')); | ||
@@ -47,41 +46,10 @@ var rimraf = require('rimraf'); | ||
function printNoYarnLockfileError() { | ||
console.error("\n" + chalk.red.bold("**ERROR**") + " " + chalk.red("The --use-yarn option was specified but there is no yarn.lock file") + "\n"); | ||
} | ||
function printNoLockfilesError() { | ||
console.error("\n" + chalk.red.bold("**ERROR**") + " " + chalk.red("No package-lock.json, npm-shrinkwrap.json, or yarn.lock file.\n\nYou must use either npm@>=5, yarn, or npm-shrinkwrap to manage this project's\ndependencies.") + "\n"); | ||
} | ||
function printSelectingDefaultMessage() { | ||
console.info(chalk.bold("copy-package") + ": you have both yarn.lock and package-lock.json\nDefaulting to using " + chalk.bold("npm") + "\nYou can override this setting by passing --use-yarn or deleting\npackage-lock.json if you don't need it\n"); | ||
} | ||
var detectPackageManager = function detectPackageManager(appRootPath, overridePackageManager) { | ||
var packageLockExists = fs__default.existsSync(join(appRootPath, "package-lock.json")); | ||
var shrinkWrapExists = fs__default.existsSync(join(appRootPath, "npm-shrinkwrap.json")); | ||
var detectPackageManager = function detectPackageManager(appRootPath) { | ||
var yarnLockExists = fs__default.existsSync(join(appRootPath, "yarn.lock")); | ||
if ((packageLockExists || shrinkWrapExists) && yarnLockExists) { | ||
if (overridePackageManager) { | ||
return overridePackageManager; | ||
} else { | ||
printSelectingDefaultMessage(); | ||
return shrinkWrapExists ? "npm-shrinkwrap" : "npm"; | ||
} | ||
} else if (packageLockExists || shrinkWrapExists) { | ||
if (overridePackageManager === "yarn") { | ||
printNoYarnLockfileError(); | ||
process$1.exit(1); | ||
} else { | ||
return shrinkWrapExists ? "npm-shrinkwrap" : "npm"; | ||
} | ||
} else if (yarnLockExists || findWorkspaceRoot()) { | ||
if (yarnLockExists || findWorkspaceRoot()) { | ||
return "yarn"; | ||
} else { | ||
printNoLockfilesError(); | ||
process$1.exit(1); | ||
} | ||
throw Error(); | ||
return "npm"; | ||
}; | ||
@@ -88,0 +56,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}var e=r(require("chalk")),n=r(require("slash")),o=r(require("path")),a=require("cross-spawn"),s=require("fs-extra"),i=r(s),t=r(require("process")),c=r(require("find-yarn-workspace-root")),p=require("rimraf"),l=require("tmp"),u=function(){return n(o.join.apply(o,arguments))},d={logStdErrOnError:!0,throwOnError:!0},y=function(r,e,n){var o=Object.assign({},d,n),s=a.sync(r,e,n);if((s.error||0!==s.status)&&(o.logStdErrOnError&&(s.stderr?console.error(s.stderr.toString()):s.error&&console.error(s.error)),o.throwOnError))throw s;return s},k=function(r,n){var o=i.existsSync(u(r,"package-lock.json")),a=i.existsSync(u(r,"npm-shrinkwrap.json")),s=i.existsSync(u(r,"yarn.lock"));if((o||a)&&s)return n||(console.info(e.bold("copy-package")+": you have both yarn.lock and package-lock.json\nDefaulting to using "+e.bold("npm")+"\nYou can override this setting by passing --use-yarn or deleting\npackage-lock.json if you don't need it\n"),a?"npm-shrinkwrap":"npm");if(o||a){if("yarn"!==n)return a?"npm-shrinkwrap":"npm";console.error("\n"+e.red.bold("**ERROR**")+" "+e.red("The --use-yarn option was specified but there is no yarn.lock file")+"\n"),t.exit(1)}else{if(s||c())return"yarn";console.error("\n"+e.red.bold("**ERROR**")+" "+e.red("No package-lock.json, npm-shrinkwrap.json, or yarn.lock file.\n\nYou must use either npm@>=5, yarn, or npm-shrinkwrap to manage this project's\ndependencies.")+"\n"),t.exit(1)}throw Error()};function f(r,n){void 0===n&&(n="*");var o=l.dirSync({unsafeCleanup:!0}),a=o.name,i=u(a,"node_modules"),t=u(a,"package.json"),c=u(i,r),d=k(process.cwd());try{var f;return s.mkdirpSync(i),s.writeFileSync(t,JSON.stringify({dependencies:(f={},f[r]=n,f)})),"yarn"===d?y("yarn",["install","--ignore-engines"],{cwd:i}):y("npm",["i"],{cwd:i}),p.sync(u(c,"node_modules")),{name:c,removeCallback:o.removeCallback}}catch(r){console.error(e.red("Uh oh")),console.log(r)}}exports.copyPackage=function(r,e,n){void 0===n&&(n="*");var o=f(e,n);s.copySync(o.name,r),o.removeCallback()},exports.copyPackageToTempDir=f; | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}var e=r(require("chalk")),n=r(require("slash")),o=r(require("path")),a=require("cross-spawn"),t=require("fs-extra"),c=r(t),i=r(require("find-yarn-workspace-root")),s=require("rimraf"),u=require("tmp"),l=function(){return n(o.join.apply(o,arguments))},d={logStdErrOnError:!0,throwOnError:!0},p=function(r,e,n){var o=Object.assign({},d,n),t=a.sync(r,e,n);if((t.error||0!==t.status)&&(o.logStdErrOnError&&(t.stderr?console.error(t.stderr.toString()):t.error&&console.error(t.error)),o.throwOnError))throw t;return t},y=function(r){return c.existsSync(l(r,"yarn.lock"))||i()?"yarn":"npm"};function f(r,n){void 0===n&&(n="*");var o=u.dirSync({unsafeCleanup:!0}),a=o.name,c=l(a,"node_modules"),i=l(a,"package.json"),d=l(c,r),f=y(process.cwd());try{var m;return t.mkdirpSync(c),t.writeFileSync(i,JSON.stringify({dependencies:(m={},m[r]=n,m)})),"yarn"===f?p("yarn",["install","--ignore-engines"],{cwd:c}):p("npm",["i"],{cwd:c}),s.sync(l(d,"node_modules")),{name:d,removeCallback:o.removeCallback}}catch(r){console.error(e.red("Uh oh")),console.log(r)}}exports.copyPackage=function(r,e,n){void 0===n&&(n="*");var o=f(e,n);t.copySync(o.name,r),o.removeCallback()},exports.copyPackageToTempDir=f; | ||
//# sourceMappingURL=copy-package.cjs.production.min.js.map |
@@ -6,3 +6,2 @@ import chalk from 'chalk'; | ||
import fs, { copySync, mkdirpSync, writeFileSync } from 'fs-extra'; | ||
import process$1 from 'process'; | ||
import findWorkspaceRoot from 'find-yarn-workspace-root'; | ||
@@ -41,41 +40,10 @@ import { sync as sync$1 } from 'rimraf'; | ||
function printNoYarnLockfileError() { | ||
console.error("\n" + chalk.red.bold("**ERROR**") + " " + chalk.red("The --use-yarn option was specified but there is no yarn.lock file") + "\n"); | ||
} | ||
function printNoLockfilesError() { | ||
console.error("\n" + chalk.red.bold("**ERROR**") + " " + chalk.red("No package-lock.json, npm-shrinkwrap.json, or yarn.lock file.\n\nYou must use either npm@>=5, yarn, or npm-shrinkwrap to manage this project's\ndependencies.") + "\n"); | ||
} | ||
function printSelectingDefaultMessage() { | ||
console.info(chalk.bold("copy-package") + ": you have both yarn.lock and package-lock.json\nDefaulting to using " + chalk.bold("npm") + "\nYou can override this setting by passing --use-yarn or deleting\npackage-lock.json if you don't need it\n"); | ||
} | ||
var detectPackageManager = function detectPackageManager(appRootPath, overridePackageManager) { | ||
var packageLockExists = fs.existsSync(join(appRootPath, "package-lock.json")); | ||
var shrinkWrapExists = fs.existsSync(join(appRootPath, "npm-shrinkwrap.json")); | ||
var detectPackageManager = function detectPackageManager(appRootPath) { | ||
var yarnLockExists = fs.existsSync(join(appRootPath, "yarn.lock")); | ||
if ((packageLockExists || shrinkWrapExists) && yarnLockExists) { | ||
if (overridePackageManager) { | ||
return overridePackageManager; | ||
} else { | ||
printSelectingDefaultMessage(); | ||
return shrinkWrapExists ? "npm-shrinkwrap" : "npm"; | ||
} | ||
} else if (packageLockExists || shrinkWrapExists) { | ||
if (overridePackageManager === "yarn") { | ||
printNoYarnLockfileError(); | ||
process$1.exit(1); | ||
} else { | ||
return shrinkWrapExists ? "npm-shrinkwrap" : "npm"; | ||
} | ||
} else if (yarnLockExists || findWorkspaceRoot()) { | ||
if (yarnLockExists || findWorkspaceRoot()) { | ||
return "yarn"; | ||
} else { | ||
printNoLockfilesError(); | ||
process$1.exit(1); | ||
} | ||
throw Error(); | ||
return "npm"; | ||
}; | ||
@@ -82,0 +50,0 @@ |
export declare type PackageManager = "yarn" | "npm" | "npm-shrinkwrap"; | ||
export declare const detectPackageManager: (appRootPath: string, overridePackageManager: "npm" | "yarn" | "npm-shrinkwrap" | null) => PackageManager; | ||
export declare const detectPackageManager: (appRootPath: string) => PackageManager; |
{ | ||
"name": "copy-package", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/copy-package.esm.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
30991
264