test: yml
This commit is contained in:
parent
bd143df524
commit
b0dbc59f6d
|
@ -7,8 +7,8 @@ const {
|
|||
FLECKS_CORE_ROOT = process.cwd(),
|
||||
} = process.env;
|
||||
|
||||
module.exports = async (paths) => {
|
||||
const ymlPath = join(FLECKS_CORE_ROOT, 'build', 'flecks.yml');
|
||||
module.exports = async (paths, root) => {
|
||||
const ymlPath = join(root || FLECKS_CORE_ROOT, 'build', 'flecks.yml');
|
||||
let yml = loadYml(await readFile(ymlPath));
|
||||
yml = Object.fromEntries(Object.entries(yml).concat(paths.map((path) => [path, {}])));
|
||||
await writeFile(ymlPath, dumpYml(yml, {sortKeys: true}));
|
||||
|
|
17
packages/build/test/server/yml.js
Normal file
17
packages/build/test/server/yml.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import {readFile, writeFile} from 'fs/promises';
|
||||
import {load as loadYml} from 'js-yaml';
|
||||
import addPathsToYml from '@flecks/build/build/add-paths-to-yml';
|
||||
import {expect} from 'chai';
|
||||
|
||||
it('can add paths to YML', async () => {
|
||||
await writeFile(
|
||||
'test/server/yml/build/flecks.yml',
|
||||
`
|
||||
bar: {}
|
||||
foo: {}
|
||||
`,
|
||||
);
|
||||
await addPathsToYml(['a', 'two'], 'test/server/yml');
|
||||
expect(Object.keys(await loadYml(await readFile('test/server/yml/build/flecks.yml'))))
|
||||
.to.deep.equal(['a', 'bar', 'foo', 'two']);
|
||||
});
|
Loading…
Reference in New Issue
Block a user