11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// Test that 'close' emits once and not twice when `emitClose: true` is set. 41cb0ef41Sopenharmony_ci// Refs: https://github.com/nodejs/node/issues/31366 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst common = require('../common'); 71cb0ef41Sopenharmony_ciconst path = require('path'); 81cb0ef41Sopenharmony_ciconst fs = require('fs'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 111cb0ef41Sopenharmony_citmpdir.refresh(); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst filepath = path.join(tmpdir.path, 'write_pos.txt'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst fileReadStream = fs.createReadStream(process.execPath); 161cb0ef41Sopenharmony_ciconst fileWriteStream = fs.createWriteStream(filepath, { 171cb0ef41Sopenharmony_ci emitClose: true 181cb0ef41Sopenharmony_ci}); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_cifileReadStream.pipe(fileWriteStream); 211cb0ef41Sopenharmony_cifileWriteStream.on('close', common.mustCall()); 22