Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jest.resetAllMocks();
// Reset env
env.env = undefined;
const root = await pkgDir();
tmpDir = await tmp.dir({ dir: tempDir, unsafeCleanup: true });
// Write kosko.toml
await writeFile(
join(tmpDir.path, "kosko.toml"),
toml.stringify(config as toml.JsonMap)
);
// Install @kosko/env in the temp folder
await symlinkDir(
join(root!, "packages", "env"),
join(tmpDir.path, "node_modules", "@kosko", "env")
);
});
getHostPkgAlias(api.paths).forEach(([pkgName, pkgPath]) => {
const srcPath = path.join(pkgPath, 'src');
const linkPath = path.join(api.paths.cwd, 'node_modules', pkgName);
// use src path instead of main field in package.json if exists
config.resolve.alias.set(pkgName, fs.existsSync(srcPath) ? srcPath : pkgPath);
// link current pkgs into node_modules, for import module resolve when writing demo
if (!fs.existsSync(linkPath)) {
symlink(pkgPath, linkPath);
}
});
});
beforeAll(async () => {
const root = await pkgDir();
await symlinkDir(
join(root!, "packages", "env"),
join(testDir, "node_modules", "@kosko", "env")
);
});
beforeEach(async () => {
const root = await pkgDir();
tmpDir = await tmp.dir({ dir: tempDir, unsafeCleanup: true });
const src = join(__dirname, "..", "bin.js");
const dst = join(tmpDir.path, "bin.js");
await copyFile(src, dst);
await symlinkDir(
join(root!, "packages", "template"),
join(tmpDir.path, "node_modules", "@kosko", "template")
);
result = await execa(dst, args, {
...options,
cwd: tmpDir.path,
env: {
LC_ALL: "en_US"
}
});
});
link(packagePath, done) {
const packageBin = path.join(packagePath, 'node_modules', '.bin')
symlinkDir(rootBin, packageBin).then(
() => done(null, true),
(err) => {
console.warn(
`Cannot create symlink '${packageBin}' (there is a directory there probably).`
)
done(err)
}
)
},
npm(cwd, done) {