How to use the yaml.default.parse function in yaml

To help you get started, we’ve selected a few yaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github back4app / antframework / packages / ant / spec / lib / config / Config.spec.js View on Github external
'  # Should not be removed below\n';
        fs.existsSync = jest.fn().mockImplementation(() => true);
        const originalFileReadSync = fs.readFileSync;
        fs.readFileSync = jest.fn().mockImplementation(() => configFileContent);

        const config = new Config(path.resolve(outPath, 'ant.yml'));
        const configPath = config.addPlugin('/foo/bar/myplugin').save();
        const actualConfigFileContent = originalFileReadSync(configPath, 'utf-8');

        // Notice that the empty line is removed when the yaml tree is rendered
        expect(actualConfigFileContent).toBe('# Should not be removed\n' +
        'plugins:\n' +
        '  - ./plugins/core\n' +
        '  - /foo/bar/myplugin\n' +
        '  # Should not be removed below\n');
        expect(yaml.parse(actualConfigFileContent)).toEqual(
          { plugins: [ './plugins/core', '/foo/bar/myplugin' ] }
        );
      }
    );
github back4app / antframework / plugins / ant-core / spec / lib / Core.spec.js View on Github external
test('Should be rendered by createService', async () => {
          const outPath = await (new Core(new Ant())).createService(
            'MyService',
            'Default'
          );
          expect(fs.readdirSync(outPath)).toEqual(['ant.yml', 'model.graphql']);
          expect(
            yaml.parse(
              fs.readFileSync(path.resolve(outPath, 'ant.yml'), 'utf8')
            ).service
          ).toEqual('MyService');
          makeExecutableSchema({
            typeDefs: fs.readFileSync(
              path.resolve(outPath, 'model.graphql'),
              'utf8'
            )
          });
          const originalCwd = process.cwd();
          process.chdir(path.resolve(
            utilPath,
            'configs/graphQLPluginConfig'
          ));
          const originalLog = console.log;
          console.log = jest.fn();
github the-couch / slater-cli / index.js View on Github external
const {
  _: args,
  config: configFile = 'slater.config.js',
  env = 'development',
  debug,
  ...props
} = require('minimist')(process.argv.slice(2))

if (debug) require('inspector').open()

const watch = args[0] === 'watch'
const deploy = args[0] === 'deploy'
const build = args[0] === 'build' || (!watch && !deploy)
const gitignore = fs.readFileSync(join('.gitignore'))
const userConfig = fs.existsSync(join(configFile)) ? require(join(configFile)) : {}
const themeConfig = yaml.parse(fs.readFileSync(join('src/config.yml'), 'utf8'))[env]

let ignoredFiles = [
  '**/scripts/**',
  '**/styles/**',
  /DS_Store/
].concat(
  themeConfig.ignore_files || []
).concat(
  gitignore ? require('parse-gitignore')(gitignore) : []
)

const theme = themekit({
  password: themeConfig.password,
  store: themeConfig.store,
  theme_id: themeConfig.theme_id,
  ignore_files: ignoredFiles
github back4app / antframework / packages / ant / spec / lib / config / Config.spec.js View on Github external
async () => {
          const configFilePath = path.resolve(outPath, 'ant.yml');
          fsExtra.ensureFileSync(configFilePath);
          let config = new Config(configFilePath);
          const localConfigFilePath = config.addPlugin('/reading/from/file').save();

          config = new Config(localConfigFilePath);
          const configPath = config.removePlugin('/reading/from/file').save();
          expect(configPath).toBe(localConfigFilePath);
          expect(yaml.parse(fs.readFileSync(configPath, 'utf-8'))).toEqual({ plugins: [] });
        }
      );