Skip to content

Commit

Permalink
feat: add a yalc-using package
Browse files Browse the repository at this point in the history
The `yalc publish` command now copies (but never hashes) the local
".yalc" directory to the global store.

Also, the "yalc.lock" file is always copied/hashed now.
  • Loading branch information
aleclarson committed Jan 20, 2019
1 parent 3a24a86 commit 6827aa9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ignore from 'ignore'

import { execSync } from 'child_process'
import { join, dirname } from 'path'
import { readIgnoreFile, readSignatureFile, getPackageManager } from '.'
import { readIgnoreFile, readSignatureFile, getPackageManager, values } from '.'
import {
PackageManifest,
getStorePackagesDir,
Expand Down Expand Up @@ -66,12 +66,16 @@ export const copyPackageToStore = async (
const npmList: string[] = await npmPacklist({ path: workingDir })
const filesToCopy = npmList.filter(f => !ignoreRule.ignores(f))

// Ensure the lockfile is always copied.
// Ensure any lockfiles are copied...
const npmBin = getPackageManager(workingDir)
const lockfileName = npmBin === 'yarn' ? 'yarn.lock' : 'package-lock.json'
if (fs.existsSync(join(workingDir, lockfileName))) {
filesToCopy.push(lockfileName)
}
// ...including "yalc.lock"
if (fs.existsSync(join(workingDir, values.lockfileName))) {
filesToCopy.push(values.lockfileName)
}

if (options.files) {
console.log('Files included in published content:')
Expand All @@ -89,6 +93,16 @@ export const copyPackageToStore = async (

const copyFilesToStore = async () => {
await fs.remove(storePackageStoreDir)

// The local ".yalc" directory is copied but not hashed.
const yalcLocalCacheDir = join(workingDir, values.yalcPackagesFolder)
if (fs.existsSync(yalcLocalCacheDir)) {
fs.copySync(
yalcLocalCacheDir,
join(storePackageStoreDir, values.yalcPackagesFolder)
)
}

return Promise.all(
filesToCopy
.sort()
Expand Down

0 comments on commit 6827aa9

Please sign in to comment.