fs#rmSync JavaScript Examples
The following examples show how to use
fs#rmSync.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: builder.spec.js From kit with MIT License | 5 votes |
test('copy files', () => {
const cwd = join(__dirname, 'fixtures/basic');
const outDir = join(cwd, '.svelte-kit');
/** @type {import('types').Config} */
const mocked = {
extensions: ['.svelte'],
kit: {
appDir: '_app',
files: {
assets: join(__dirname, 'fixtures/basic/static')
},
outDir
}
};
const builder = create_builder({
config: /** @type {import('types').ValidatedConfig} */ (mocked),
// @ts-expect-error
build_data: {},
// @ts-expect-error
prerendered: {
paths: []
},
// @ts-expect-error
log: {}
});
const dest = join(__dirname, 'output');
rmSync(dest, { recursive: true, force: true });
builder.writeStatic(dest);
assert.equal(
glob('**', {
cwd: /** @type {import('types').ValidatedConfig} */ (mocked).kit.files.assets,
dot: true
}),
glob('**', { cwd: dest, dot: true })
);
rmSync(dest, { recursive: true, force: true });
builder.writeClient(dest);
assert.equal(
glob('**', { cwd: `${outDir}/output/client`, dot: true }),
glob('**', { cwd: dest, dot: true })
);
rmSync(dest, { recursive: true, force: true });
builder.writeServer(dest);
assert.equal(
glob('**', { cwd: `${outDir}/output/server`, dot: true }),
glob('**', { cwd: dest, dot: true })
);
rmSync(dest, { force: true, recursive: true });
});