Remove custom copySync function

Originally we introduced this function because we thought empty
directories were causing path length issues on Windows, but it turns out
that it was a problem with Squirrel, so we can delete this code path
altogether.

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Antonio Scandurra 2016-08-16 18:08:16 +02:00 committed by Nathan Sobo
parent f139c800e2
commit 061ae3786a
6 changed files with 23 additions and 81 deletions

View File

@ -4,7 +4,7 @@
'use strict'
const path = require('path')
const copySync = require('./copy-sync')
const fs = require('fs-extra')
const CONFIG = require('../config')
const glob = require('glob')
const includePathInPackagedApp = require('./include-path-in-packaged-app')
@ -22,10 +22,10 @@ module.exports = function () {
]
srcPaths = srcPaths.concat(glob.sync(path.join(CONFIG.repositoryRootPath, 'spec', '*.*'), {ignore: path.join('**', '*-spec.*')}))
for (let srcPath of srcPaths) {
copySync(srcPath, computeDestinationPath(srcPath), {filter: includePathInPackagedApp})
fs.copySync(srcPath, computeDestinationPath(srcPath), {filter: includePathInPackagedApp})
}
copySync(
fs.copySync(
path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'png', '1024.png'),
path.join(CONFIG.intermediateAppPath, 'resources', 'atom.png')
)

View File

@ -1,54 +0,0 @@
'use strict'
const fs = require('fs-extra')
const path = require('path')
module.exports = copySync
function copySync(src, dest, opts) {
const options = Object.assign({filter: () => true}, opts || {})
const stat = fs.lstatSync(src)
if (options.filter(src)) {
if (stat.isFile()) {
const destDirPath = path.dirname(dest)
if (!fs.existsSync(destDirPath)) {
fs.mkdirpSync(destDirPath)
}
copyFileSync(src, dest, options)
} else if (stat.isDirectory()) {
if (!fs.existsSync(dest)) {
fs.mkdirpSync(dest)
}
fs.readdirSync(src).forEach(content => {
copySync(path.join(src, content), path.join(dest, content), options)
})
} else if (stat.isSymbolicLink()) {
fs.symlinkSync(fs.readlinkSync(src), dest)
}
}
}
const BUF_LENGTH = 4096
const _buff = new Buffer(BUF_LENGTH)
function copyFileSync(srcFile, destFile) {
if (fs.existsSync(destFile)) {
fs.chmodSync(destFile, parseInt('777', 8))
fs.unlinkSync(destFile)
}
const fileRead = fs.openSync(srcFile, 'r')
const stat = fs.fstatSync(fileRead)
const fileWrite = fs.openSync(destFile, 'w', stat.mode)
let bytesRead = 1
let pos = 0
while (bytesRead > 0) {
bytesRead = fs.readSync(fileRead, _buff, 0, BUF_LENGTH, pos)
fs.writeSync(fileWrite, _buff, 0, bytesRead)
pos += bytesRead
}
fs.closeSync(fileRead)
fs.closeSync(fileWrite)
}

View File

@ -1,6 +1,5 @@
'use strict'
const copySync = require('./copy-sync')
const fs = require('fs-extra')
const os = require('os')
const path = require('path')
@ -62,11 +61,11 @@ module.exports = function (packagedAppPath) {
fs.mkdirpSync(debianPackageBinDirPath)
console.log(`Copying "${packagedAppPath}" to "${debianPackageAtomDirPath}"`)
copySync(packagedAppPath, debianPackageAtomDirPath)
fs.copySync(packagedAppPath, debianPackageAtomDirPath)
fs.chmodSync(debianPackageAtomDirPath, '755')
console.log(`Copying binaries into "${debianPackageBinDirPath}"`)
copySync(path.join(CONFIG.repositoryRootPath, 'atom.sh'), path.join(debianPackageBinDirPath, atomExecutableName))
fs.copySync(path.join(CONFIG.repositoryRootPath, 'atom.sh'), path.join(debianPackageBinDirPath, atomExecutableName))
fs.symlinkSync(
path.join('..', 'share', atomExecutableName, 'resources', 'app', 'apm', 'node_modules', '.bin', 'apm'),
path.join(debianPackageBinDirPath, apmExecutableName)
@ -90,19 +89,19 @@ module.exports = function (packagedAppPath) {
fs.writeFileSync(path.join(debianPackageApplicationsDirPath, `${atomExecutableName}.desktop`), desktopEntryContents)
console.log(`Copying icon into "${debianPackageIconsDirPath}"`)
copySync(
fs.copySync(
path.join(packagedAppPath, 'resources', 'app.asar.unpacked', 'resources', 'atom.png'),
path.join(debianPackageIconsDirPath, `${atomExecutableName}.png`)
)
console.log(`Copying license into "${debianPackageDocsDirPath}"`)
copySync(
fs.copySync(
path.join(packagedAppPath, 'resources', 'LICENSE.md'),
path.join(debianPackageDocsDirPath, 'copyright')
)
console.log(`Copying lintian overrides into "${debianPackageLintianOverridesDirPath}"`)
copySync(
fs.copySync(
path.join(CONFIG.repositoryRootPath, 'resources', 'linux', 'debian', 'lintian-overrides'),
path.join(debianPackageLintianOverridesDirPath, atomExecutableName)
)
@ -111,5 +110,5 @@ module.exports = function (packagedAppPath) {
spawnSync('fakeroot', ['dpkg-deb', '-b', debianPackageDirPath], {stdio: 'inherit'})
console.log(`Copying generated package into "${outputDebianPackageFilePath}"`)
copySync(`${debianPackageDirPath}.deb`, outputDebianPackageFilePath)
fs.copySync(`${debianPackageDirPath}.deb`, outputDebianPackageFilePath)
}

View File

@ -1,7 +1,6 @@
'use strict'
const assert = require('assert')
const copySync = require('./copy-sync')
const fs = require('fs-extra')
const os = require('os')
const path = require('path')
@ -48,10 +47,10 @@ module.exports = function (packagedAppPath) {
fs.mkdirpSync(rpmPackageSpecsDirPath)
console.log(`Copying "${packagedAppPath}" to "${rpmPackageApplicationDirPath}"`)
copySync(packagedAppPath, rpmPackageApplicationDirPath)
fs.copySync(packagedAppPath, rpmPackageApplicationDirPath)
console.log(`Copying icons into "${rpmPackageIconsDirPath}"`)
copySync(
fs.copySync(
path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'png'),
rpmPackageIconsDirPath
)
@ -74,7 +73,7 @@ module.exports = function (packagedAppPath) {
fs.writeFileSync(path.join(rpmPackageBuildDirPath, `${atomExecutableName}.desktop`), desktopEntryContents)
console.log(`Copying atom.sh into "${rpmPackageBuildDirPath}"`)
copySync(
fs.copySync(
path.join(CONFIG.repositoryRootPath, 'atom.sh'),
path.join(rpmPackageBuildDirPath, 'atom.sh')
)
@ -88,6 +87,6 @@ module.exports = function (packagedAppPath) {
const generatedPackageFilePath = path.join(generatedArchDirPath, generatedPackageFileNames[0])
const outputRpmPackageFilePath = path.join(CONFIG.buildOutputPath, `atom.${generatedArch}.rpm`)
console.log(`Copying "${generatedPackageFilePath}" into "${outputRpmPackageFilePath}"`)
copySync(generatedPackageFilePath, outputRpmPackageFilePath)
fs.copySync(generatedPackageFilePath, outputRpmPackageFilePath)
}
}

View File

@ -1,6 +1,5 @@
'use strict'
const copySync = require('./copy-sync')
const fs = require('fs-extra')
const path = require('path')
@ -13,7 +12,7 @@ module.exports = function (packagedAppPath) {
fs.removeSync(installationDirPath)
}
console.log(`Installing ${packagedAppPath} at ${installationDirPath}`)
copySync(packagedAppPath, installationDirPath)
fs.copySync(packagedAppPath, installationDirPath)
} else {
throw new Error("Not implemented yet.")
}

View File

@ -2,7 +2,6 @@
const assert = require('assert')
const childProcess = require('child_process')
const copySync = require('./copy-sync')
const electronPackager = require('electron-packager')
const fs = require('fs-extra')
const includePathInPackagedApp = require('./include-path-in-packaged-app')
@ -58,7 +57,7 @@ module.exports = function () {
function copyNonASARResources (packagedAppPath, bundledResourcesPath) {
console.log(`Copying non-ASAR resources to ${bundledResourcesPath}`)
copySync(
fs.copySync(
path.join(CONFIG.repositoryRootPath, 'apm', 'node_modules', 'atom-package-manager'),
path.join(bundledResourcesPath, 'app', 'apm'),
{filter: includePathInPackagedApp}
@ -67,18 +66,18 @@ function copyNonASARResources (packagedAppPath, bundledResourcesPath) {
// Existing symlinks on user systems point to an outdated path, so just symlink it to the real location of the apm binary.
// TODO: Change command installer to point to appropriate path and remove this fallback after a few releases.
fs.symlinkSync(path.join('..', '..', 'bin', 'apm'), path.join(bundledResourcesPath, 'app', 'apm', 'node_modules', '.bin', 'apm'))
copySync(path.join(CONFIG.repositoryRootPath, 'atom.sh'), path.join(bundledResourcesPath, 'app', 'atom.sh'))
fs.copySync(path.join(CONFIG.repositoryRootPath, 'atom.sh'), path.join(bundledResourcesPath, 'app', 'atom.sh'))
}
if (process.platform === 'darwin') {
copySync(path.join(CONFIG.repositoryRootPath, 'resources', 'mac', 'file.icns'), path.join(bundledResourcesPath, 'file.icns'))
fs.copySync(path.join(CONFIG.repositoryRootPath, 'resources', 'mac', 'file.icns'), path.join(bundledResourcesPath, 'file.icns'))
} else if (process.platform === 'linux') {
copySync(path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'png', '1024.png'), path.join(packagedAppPath, 'atom.png'))
fs.copySync(path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'png', '1024.png'), path.join(packagedAppPath, 'atom.png'))
} else if (process.platform === 'win32') {
copySync(path.join('resources', 'win', 'atom.cmd'), path.join(bundledResourcesPath, 'cli', 'atom.cmd'))
copySync(path.join('resources', 'win', 'atom.sh'), path.join(bundledResourcesPath, 'cli', 'atom.sh'))
copySync(path.join('resources', 'win', 'atom.js'), path.join(bundledResourcesPath, 'cli', 'atom.js'))
copySync(path.join('resources', 'win', 'apm.cmd'), path.join(bundledResourcesPath, 'cli', 'apm.cmd'))
copySync(path.join('resources', 'win', 'apm.sh'), path.join(bundledResourcesPath, 'cli', 'apm.sh'))
fs.copySync(path.join('resources', 'win', 'atom.cmd'), path.join(bundledResourcesPath, 'cli', 'atom.cmd'))
fs.copySync(path.join('resources', 'win', 'atom.sh'), path.join(bundledResourcesPath, 'cli', 'atom.sh'))
fs.copySync(path.join('resources', 'win', 'atom.js'), path.join(bundledResourcesPath, 'cli', 'atom.js'))
fs.copySync(path.join('resources', 'win', 'apm.cmd'), path.join(bundledResourcesPath, 'cli', 'apm.cmd'))
fs.copySync(path.join('resources', 'win', 'apm.sh'), path.join(bundledResourcesPath, 'cli', 'apm.sh'))
}
console.log(`Writing LICENSE.md to ${bundledResourcesPath}`)