runs(() => { expect(atom.project.getBuffers().length).toBe(1) fs.unlinkSync(pathToOpen) deserializedProject = new Project({ notificationManager: atom.notifications, packageManager: atom.packages, confirm: atom.confirm, grammarRegistry: atom.grammars }) })
/** * Remove the cached javascript for the provided file path. * * @param {String} filePath - The file path. * * @returns {null} null. */ _removeCachedJavascript(filePath) { const compiler = COMPILERS[path.extname(filePath)]; const digestedPath = this._digestedPath(compiler, filePath); const cachePath = path.join(this.cacheDirectory, digestedPath); try { debug(`Removing cache digest for: ${filePath}`); return fs.unlinkSync(cachePath); } catch (error) { return null; } }
glob.sync(pattern, {cwd: buildPath, absolute: true}).forEach((es6Path) => { const outPath = es6Path.replace(path.extname(es6Path), '.js'); const res = babel.transformFileSync(es6Path, Object.assign(babelOptions, { sourceMaps: true, sourceRoot: '/', sourceMapTarget: path.relative(buildPath, outPath), sourceFileName: path.relative(buildPath, es6Path), })); grunt.file.write(outPath, `${res.code}\n//# sourceMappingURL=${path.basename(outPath)}.map\n`); grunt.file.write(`${outPath}.map`, JSON.stringify(res.map)); fs.unlinkSync(es6Path); });
deleteSocketFile () { if (process.platform === 'win32' || !this.socketPath) return if (fs.existsSync(this.socketPath)) { try { fs.unlinkSync(this.socketPath) } catch (error) { // Ignore ENOENT errors in case the file was deleted between the exists // check and the call to unlink sync. This occurred occasionally on CI // which is why this check is here. if (error.code !== 'ENOENT') throw error } } }
beforeEach(function() { directory = fs.realpathSync(temp.mkdirSync({ prefix: 'atom-build-spec-' })) + '/'; atom.project.setPaths([ directory ]); atom.config.set('build.buildOnSave', false); atom.config.set('build.keepVisible', false); atom.config.set('build.saveOnBuild', false); // Set up dependencies fs.copySync(path.join(__dirname, 'fixture', 'node_modules'), path.join(directory, 'node_modules')); // Set up grunt var binGrunt = path.join(directory, 'node_modules', '.bin', 'grunt'); var realGrunt = path.join(directory, 'node_modules', 'grunt-cli', 'bin', 'grunt'); fs.unlinkSync(binGrunt); fs.chmodSync(realGrunt, parseInt('0700', 8)); fs.symlinkSync(realGrunt, binGrunt); // Set up gulp var binGulp = path.join(directory, 'node_modules', '.bin', 'gulp'); var realGulp = path.join(directory, 'node_modules', 'gulp', 'bin', 'gulp.js'); fs.unlinkSync(binGulp); fs.chmodSync(realGulp, parseInt('0700', 8)); fs.symlinkSync(realGulp, binGulp); jasmine.unspy(window, 'setTimeout'); jasmine.unspy(window, 'clearTimeout'); runs(function() { workspaceElement = atom.views.getView(atom.workspace); jasmine.attachToDOM(workspaceElement); }); waitsForPromise(function() { return atom.packages.activatePackage('build'); }); });
glob.sync(pattern, {cwd: buildPath, absolute: true}).forEach((coffeepath) => { const outPath = coffeepath.replace(path.extname(coffeepath), '.js'); const res = coffeereact.compile(grunt.file.read(coffeepath), { bare: false, join: false, separator: grunt.util.normalizelf(grunt.util.linefeed), sourceMap: true, sourceRoot: '/', generatedFile: path.basename(outPath), sourceFiles: [path.relative(buildPath, coffeepath)], }); grunt.file.write(outPath, `${res.js}\n//# sourceMappingURL=${path.basename(outPath)}.map\n`); grunt.file.write(`${outPath}.map`, res.v3SourceMap); fs.unlinkSync(coffeepath); });
function runCopyAPM(buildPath, electronVersion, platform, arch, callback) { // Move APM up out of the /app folder which will be inside the ASAR const apmTargetDir = path.resolve(buildPath, '..', 'apm'); fs.moveSync(path.join(buildPath, 'apm'), apmTargetDir) // Move /apm/node_modules/atom-package-manager up a level. We're essentially // pulling the atom-package-manager module up outside of the node_modules folder, // which is necessary because npmV3 installs nested dependencies in the same dir. const apmPackageDir = path.join(apmTargetDir, 'node_modules', 'atom-package-manager') for (const name of fs.readdirSync(apmPackageDir)) { fs.renameSync(path.join(apmPackageDir, name), path.join(apmTargetDir, name)); } const apmSymlink = path.join(apmTargetDir, 'node_modules', '.bin', 'apm'); if (fs.existsSync(apmSymlink)) { fs.unlinkSync(apmSymlink); } fs.rmdirSync(apmPackageDir); callback(); }
bufferAction.onDELETED(function (b, unlink) { const editors = that.atomEditors[b.id]; _.each(editors, function (editor) { that.atomEditors[IMAGINARY_ID].push(editor); }); delete that.atomEditors[b.id]; delete that.atomBuffers[b.id]; if (!unlink) { return; } const abs_path = b.abs_path(); that.ignore_events = true; try { /*eslint-disable no-sync */ fs.unlinkSync(abs_path); /*eslint-enable no-sync */ that.willUnlink[abs_path] = Date.now(); } catch (e) { if (e.code !== "ENOENT") { console.error(e); } } const parent_dir = path.dirname(abs_path); try { /*eslint-disable no-sync */ fs.rmdirSync(parent_dir); /*eslint-enable no-sync */ that.willUnlink[parent_dir] = Date.now(); } catch (e) { if (!_.includes(["ENOENT", "ENOTEMPTY"], e.code)) { console.error(e); } } that.ignore_events = false; });
glob.sync(pattern, { cwd: buildPath }).forEach(relPath => { const es6Path = path.join(buildPath, relPath); if (/(node_modules|\.js$)/.test(es6Path)) return; const outPath = es6Path.replace(path.extname(es6Path), '.js'); console.log(` ---> Compiling ${es6Path.slice(es6Path.indexOf('/app') + 4)}`); const res = babel.transformFileSync( es6Path, Object.assign(babelOptions, { sourceMaps: true, sourceRoot: '/', sourceMapTarget: path.relative(buildPath, outPath), sourceFileName: path.relative(buildPath, es6Path), }) ); grunt.file.write( outPath, `${res.code}\n//# sourceMappingURL=${path.basename(outPath)}.map\n` ); grunt.file.write(`${outPath}.map`, JSON.stringify(res.map)); fs.unlinkSync(es6Path); });