
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
gulp-sync-json
Advanced tools
Gulp plugin for synchronizing JSON file key structures against a primary source
This plugin can synchronize the key structures of JSON files. It must be provided a 'source of truth', or primary filename. For each directory it encounters, the plugin will make all JSON files present conform to that directory's primary file's key structure. It is recursive, so it handles nested key structures as one would expect.
This plugin has no relation to grunt-sync-json.
MIT License (Expat)
Given these files:
a.json
{
"key_one": "value",
"key_two": 42,
"nested": {
"key": "nested value"
}
}
b.json
{
"key_two": 100,
"nested": {
"key": "different value",
"other_key": "other value"
}
}
Running the plugin with a.json as the primary file will change b.json to the following:
{
"key_one": "value",
"key_two": 100,
"nested": {
"key": "different value"
}
}
To make all JSON files within the cwd conform to an 'en.json' sibling file:
var gulp = require('gulp');
var syncJSON = require('gulp-sync-json');
gulp.task('sync-json', function() {
return gulp.src('./**/*.json')
.pipe(syncJSON('en.json'))
.pipe(gulp.dest('./'));
});
syncJSON(primaryFile: string, options?: {
report?: boolean,
errorOnReportFail?: boolean,
spaces?: number,
verbose?: boolean
})
A filename, or the basename portion of a path, that is the source of truth for key structure for every other JSON file in the directory
An optional options object. The following properties are supported; all are optional:
report
- Default false
. If set to true
, the plugin will audit
files instead of changing them on the filesystem. Key mismatches are
treated as errors and (almost) all errors are supressed and collected
instead of being emitted onto the stream as they occur. If the audit
finds anything it will log everything out at the enderrorOnReportFail
- Default false
. If set to true
, the plugin
will emit an error onto the stream if report
mode finds anything.
Since this causes gulp to exit with a non-zero exit code, it's possible
to fail a CI/build step with this. The error is emitted after auditing
all files in the stream, and after logging the report output. Has no
effect if report
is false
spaces
- Default 4
. How many spaces to use when formatting JSON.
Passed directly to JSON.stringifyverbose
- Default false
. If set to true
, the plugin will
log out a summary of key additions and removals as it processes each
fileNeed to handle line endings differently? Pipe the results through gulp-eol.
FAQs
Gulp plugin to synchronize JSON file key structures
The npm package gulp-sync-json receives a total of 0 weekly downloads. As such, gulp-sync-json popularity was classified as not popular.
We found that gulp-sync-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.