Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function writeFile(
path: string,
data: Buffer | string,
encoding?: string
): void {
// ensure path exists
writeSync(pathmod.dirname(path), {});
if (encoding === undefined) {
writeFileSync(path, data);
} else {
writeFileSync(path, data, encoding);
}
}
execution.addListener( "message", function( data ) {
assert.step( data );
if ( data === "runEnd" ) {
count++;
if ( count === 1 ) {
fixturify.writeSync( fixturePath, {
"tests": {
"foo.js": `
process.send(require('../bar.js'));
QUnit.module('Module');
QUnit.test('Test', function(assert) {
assert.ok(true);
});`
},
"bar.js": "module.exports = 'bar export first';"
} );
}
if ( count === 2 ) {
fixturify.writeSync( fixturePath, {
"bar.js": "module.exports = 'bar export second';"
} );
test.serial.cb('detect file addition', t => {
fixturify.writeSync('.', {
'brunch-config.js': `module.exports = {
files: {
javascripts: {
joinTo: 'app.js'
}
}
};`,
app: {
assets: {
'index.html': '<h1>hello world</h1>',
},
'initialize.js': 'console.log("hello world")',
},
});
watch({}, function* (compilation) {
test.serial.cb('customize paths.public config', t => {
fixturify.writeSync('.', {
'brunch-config.js': `module.exports = {
files: {
javascripts: {
joinTo: 'app.js'
}
},
paths: {
public: 'dist'
}
};`,
app: {
assets: {
'index.html': '<h1>hello world</h1>',
},
'initialize.js': 'console.log("hello world")',
},
export function writeTree(path: string, tree: Tree): void {
writeSync(path, tree);
}
FixtureTree.prototype.write = function (readTree, destDir) {
fixturify.writeSync(destDir, this.fixtureObject)
}
test.serial.cb('reuse javascripts.joinTo for templates.joinTo', t => {
const files = {
'brunch-config.js': `module.exports = {
files: {
javascripts: {
joinTo: 'all.js'
}
}
};`,
app: {
'a.emp': 'hello-world',
'b.emp': 'module-exports',
},
};
fixturify.writeSync('.', Object.assign(files, TempCompiler));
brunch.build({}, () => {
fileContains(t, 'public/all.js', 'hello^world');
fileContains(t, 'public/all.js', 'module^exports');
t.end();
});
});
writeFixture(fixture) {
fixturify.writeSync(this.path, fixture);
}