From 1c7a13fe68c5ac66331e478e24f658269fd69fdc Mon Sep 17 00:00:00 2001 From: Olli Vanhoja Date: Fri, 30 Dec 2016 19:44:18 +0200 Subject: [PATCH] Add an option to copy symlinks (#191) --- bin/now-deploy.js | 5 +++++ lib/index.js | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/now-deploy.js b/bin/now-deploy.js index 2bb1998..b440413 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -39,6 +39,7 @@ const argv = minimist(process.argv.slice(2), { 'version', 'debug', 'force', + 'links', 'login', 'no-clipboard', 'forward-npm', @@ -55,6 +56,7 @@ const argv = minimist(process.argv.slice(2), { force: 'f', token: 't', forceSync: 'F', + links: 'l', login: 'L', public: 'p', 'no-clipboard': 'C', @@ -90,6 +92,7 @@ const help = () => { -f, --force Force a new deployment even if nothing has changed -t ${chalk.underline('TOKEN')}, --token=${chalk.underline('TOKEN')} Login token -L, --login Configure login + -l, --links Copy symlinks without resolving their target -p, --public Deployment is public (${chalk.dim('`/_src`')} is exposed) [on for oss, off for premium] -e, --env Include an env var (e.g.: ${chalk.dim('`-e KEY=value`')}). Can appear many times. -C, --no-clipboard Do not attempt to copy URL to clipboard @@ -158,6 +161,7 @@ const clipboard = !argv['no-clipboard'] const forwardNpm = argv['forward-npm'] const forceSync = argv.forceSync const shouldLogin = argv.login +const followSymlinks = !argv.links const wantsPublic = argv.public const deploymentName = argv.name || false const apiUrl = argv.url || 'https://api.zeit.co' @@ -459,6 +463,7 @@ async function sync(token) { env, deploymentType, deploymentName, + followSymlinks, forceNew, forceSync, forwardNpm: alwaysForwardNpm || forwardNpm, diff --git a/lib/index.js b/lib/index.js index a03eb6d..7f3474d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,7 +10,7 @@ import resumer from 'resumer' import retry from 'async-retry' import splitArray from 'split-array' import {parse as parseIni} from 'ini' -import {readFile, stat} from 'fs-promise' +import {readFile, stat, lstat} from 'fs-promise' // Ours import {npm as getNpmFiles, docker as getDockerFiles} from './get-files' @@ -40,6 +40,7 @@ export default class Now extends EventEmitter { wantsPublic, quiet = false, env = {}, + followSymlinks = true, forceNew = false, forceSync = false, forwardNpm = false, @@ -132,7 +133,7 @@ export default class Now extends EventEmitter { name = this.pathInsideContent(name) } - const st = await stat(name) + const st = await (followSymlinks ? stat(name) : lstat(name)) return { sha,