Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const validate = async function ({ directory, repository }) {
/* eslint-disable global-require */
const packageJson = require(path.join(directory, 'package.json'));
/* eslint-enable global-require */
assert.that(packageJson.version).is.equalTo('1.0.0');
const listTags = shell.ls(`${repository}/refs/tags`);
const tags = listTags.stdout.split('\n');
assert.that(tags[0]).is.equalTo('1.0.0');
};
test('has configure and getLogger functions.', async (): Promise => {
/* eslint-disable @typescript-eslint/unbound-method */
assert.that(flaschenpost.configure).is.ofType('function');
assert.that(flaschenpost.getLogger).is.ofType('function');
/* eslint-enable @typescript-eslint/unbound-method */
});
test('has configure and getLogger functions.', async (): Promise => {
/* eslint-disable @typescript-eslint/unbound-method */
assert.that(flaschenpost.configure).is.ofType('function');
assert.that(flaschenpost.getLogger).is.ofType('function');
/* eslint-enable @typescript-eslint/unbound-method */
});
const constraint = `>=${latestVersion} <${semver.inc(latestVersion, 'major')}`;
/* eslint-disable global-require */
const packageJson = await fs.readFile(path.join(directory, 'package.json'), { encoding: 'utf-8' });
/* eslint-enable global-require */
const newPackageJson = stripIndent`
{
"name": "test-package",
"version": "0.0.1",
"engines": {
"node": "${constraint}"
}
}`;
assert.that(packageJson).is.atLeast(`${newPackageJson}\n`);
};
const validate = async function ({ directory }) {
/* eslint-disable global-require */
const packageJson = require(path.join(directory, 'package.json'));
/* eslint-enable global-require */
assert.that(packageJson.version).is.equalTo('0.1.0');
};
test('returns a clone of the configuration with a new application.', async (): Promise => {
const newApplication = {
name: 'new-application',
version: '13.3.7'
};
const newConfiguration = defaultConfiguration.withApplication(newApplication);
assert.that(newConfiguration).is.not.sameAs(defaultConfiguration);
assert.that(newConfiguration.application).is.sameAs(newApplication);
assert.that(newConfiguration.debugModuleFilter).is.equalTo(defaultConfiguration.debugModuleFilter);
assert.that(newConfiguration.formatter).is.equalTo(defaultConfiguration.formatter);
assert.that(newConfiguration.highestEnabledLogLevel).is.equalTo(defaultConfiguration.highestEnabledLogLevel);
assert.that(newConfiguration.hostname).is.equalTo(defaultConfiguration.hostname);
assert.that(newConfiguration.logEntryIdGenerator).is.equalTo(defaultConfiguration.logEntryIdGenerator);
});
});
test('is a function.', async (): Promise => {
assert.that(asJson).is.ofType('function');
});
test('returns a clone of the configuration with a new application.', async (): Promise => {
const newApplication = {
name: 'new-application',
version: '13.3.7'
};
const newConfiguration = defaultConfiguration.withApplication(newApplication);
assert.that(newConfiguration).is.not.sameAs(defaultConfiguration);
assert.that(newConfiguration.application).is.sameAs(newApplication);
assert.that(newConfiguration.debugModuleFilter).is.equalTo(defaultConfiguration.debugModuleFilter);
assert.that(newConfiguration.formatter).is.equalTo(defaultConfiguration.formatter);
assert.that(newConfiguration.highestEnabledLogLevel).is.equalTo(defaultConfiguration.highestEnabledLogLevel);
assert.that(newConfiguration.hostname).is.equalTo(defaultConfiguration.hostname);
assert.that(newConfiguration.logEntryIdGenerator).is.equalTo(defaultConfiguration.logEntryIdGenerator);
});
});
test('is a function.', async (): Promise => {
assert.that(readPackageJson).is.ofType('function');
});
test('returns unknown as name and version if no package.json exists in the given directory.', async (): Promise => {
const directory = path.join(__dirname, '..', 'shared', 'packageJsonMissing');
const packageJson = readPackageJson(directory);
assert.that(packageJson).is.equalTo({
name: '(unknown)',
version: '(unknown)'
});
});