MCPcopy Create free account
hub / github.com/kentcdodds/kcd-scripts / writeExtraEntry

Function writeExtraEntry

src/utils.js:151–172  ·  view source on GitHub ↗
(name, {cjs, esm}, clean = true)

Source from the content-addressed store, hash-verified

149}
150
151function writeExtraEntry(name, {cjs, esm}, clean = true) {
152 if (clean) {
153 rimraf.sync(fromRoot(name))
154 }
155 mkdirp.sync(fromRoot(name))
156
157 const pkgJson = fromRoot(`${name}/package.json`)
158 const entryDir = fromRoot(name)
159
160 fs.writeFileSync(
161 pkgJson,
162 JSON.stringify(
163 {
164 main: path.relative(entryDir, cjs),
165 'jsnext:main': path.relative(entryDir, esm),
166 module: path.relative(entryDir, esm),
167 },
168 null,
169 2,
170 ),
171 )
172}
173
174function hasLocalConfig(moduleName, searchOptions = {}) {
175 const explorerSync = cosmiconfigSync(moduleName, searchOptions)

Callers 1

onwriteFunction · 0.85

Calls 1

fromRootFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…