MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / syncRun

Function syncRun

examples/next-rsc-dynamic/contentlayer.config.ts:30–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28 console.log(`Syncing content files from git (${gitTag}) to ${contentDir}`)
29
30 const syncRun = async () => {
31 const gitUrl = 'https://github.com/vercel/next.js.git'
32 await runBashCommand(`
33 #! /usr/bin/env bash
34
35 sync_lock_file="${contentDir}/.sync.lock"
36
37 function contentlayer_sync_run () {
38 block_if_locked;
39
40 mkdir -p ${contentDir};
41 touch $sync_lock_file;
42
43 if [ -d "${contentDir}/.git" ];
44 then
45 cd "${contentDir}";
46 git fetch --quiet --depth=1 origin ${gitTag};
47 git checkout --quiet FETCH_HEAD;
48 else
49 git init --quiet ${contentDir};
50 cd ${contentDir};
51 git remote add origin ${gitUrl};
52 git config core.sparsecheckout true;
53 git config advice.detachedHead false;
54 echo "docs/*" >> .git/info/sparse-checkout;
55 git checkout --quiet -b ${gitTag};
56 git fetch --quiet --depth=1 origin ${gitTag};
57 git checkout --quiet FETCH_HEAD;
58 fi
59
60 rm $sync_lock_file;
61 }
62
63 function block_if_locked () {
64 if [ -f "$sync_lock_file" ];
65 then
66 while [ -f "$sync_lock_file" ]; do sleep 1; done;
67 exit 0;
68 fi
69 }
70
71 contentlayer_sync_run
72 `)
73 }
74
75 let wasCancelled = false
76 let syncInterval

Callers 1

syncLoopFunction · 0.70

Calls 1

runBashCommandFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…