Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candidate for migration #13

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: ci
on:
- pull_request
- push

jobs:
Test:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
node_version:
- 14
- 16
- 18
exclude:
- os: windows-latest
node_version: 14
include:
- os: windows-2019
node_version: 14
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Cache
uses: actions/cache@v3
with:
path: |
node_modules
key: ${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('package.json') }}

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}

- name: Setup python
if: matrix.node_version == 14
# Old versions of Node bundle old versions of npm.
# Old versions of npm bundle old versions of node-gyp.
# Old versions of node-gyp are incompatible with Python 3.11+.
# Install older Python (Python 3.10) as a workaround.
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Python setuptools
# This is needed for Python 3.12+, since many versions of node-gyp
# are incompatible with Python 3.12+, which no-longer ships 'distutils'
# out of the box. 'setuptools' package provides 'distutils'.
run: python3 -m pip install setuptools

- name: Install dependencies
run: npm install

- name: Lint
run: npm run standard

- name: Run tests
run: |
npm run test:node
npm run test:native

Skip:
if: contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- name: Skip CI 🚫
run: echo skip ci
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ node_modules
build
.DS_Store
.clang_complete
ext

/browser.js
emsdk-portable
package-lock.json

vendor/libiconv
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
!src/bindings/*.h
!src/bindings/*.cc

!script/fetch-libiconv-61.sh

!vendor/libcxx/*

!vendor/pcre/pcre.gyp
Expand Down
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Superstring
[![macOS Build Status](https://circleci.com/gh/atom/superstring/tree/master.svg?style=shield)](https://circleci.com/gh/atom/superstring)
[![linux Build Status](https://travis-ci.org/atom/superstring.svg?branch=master)](https://travis-ci.org/atom/superstring)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/n5pack4yk7w80fso/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/superstring/branch/master)
[![Dependency Status](https://david-dm.org/atom/superstring.svg)](https://david-dm.org/atom/superstring)
[![ci](https://github.com/atom/superstring/actions/workflows/ci.yml/badge.svg)](https://github.com/atom/superstring/actions/workflows/ci.yml)

Native library at the core of Atom's text editor.

## Installation notes:

Native library at the core of Atom's text editor.
On macOS 13 and greater, the OS no longer offers GNU `libiconv`. We handle this by downloading it from Apple’s OSS GitHub page and building it as a pre-compilation step.

## Components:

Expand Down
25 changes: 2 additions & 23 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
image: Visual Studio 2015

environment:
matrix:
- nodejs_version: "8"
- nodejs_version: "12.14.1"

platform:
- x86
- x64

install:
- ps: Install-Product node $env:nodejs_version
- git submodule update --init
- node --version
- npm --version
- npm install

test_script:
- npm run standard
- npm run test:node

# empty appveyor
build: off

branches:
only:
- master
- non-existing
75 changes: 73 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,40 @@
"src/core",
"<!(node -e \"require('nan')\")"
],
"conditions": [
['OS=="mac"', {
"postbuilds": [
{
'postbuild_name': 'Adjust vendored libiconv install name',
'action': [
'install_name_tool',
"-change",
"libiconv.2.dylib",
"@loader_path/../../ext/lib/libiconv.2.dylib",
"<(PRODUCT_DIR)/superstring.node"
]

# NOTE: This version of the post-build action
# should be used if we find it necessary to avoid
# changing the `dylib`’s install name in an earlier
# step.
#
# 'action': [
# 'bash',
# '<(module_root_dir)/script/adjust-install-name.sh',
# '<(PRODUCT_DIR)'
# ]

}
]
}]
]
},
{
"target_name": "superstring_core",
"type": "static_library",
"dependencies": [
"./vendor/pcre/pcre.gyp:pcre",
"./vendor/pcre/pcre.gyp:pcre"
],
"sources": [
"src/core/encoding-conversion.cc",
Expand All @@ -46,8 +74,14 @@
],
"conditions": [
['OS=="mac"', {
'dependencies': [
'build_libiconv'
],
'include_dirs': [
'<(module_root_dir)/ext/include'
],
'link_settings': {
'libraries': ['libiconv.dylib'],
'libraries': ['<(module_root_dir)/ext/lib/libiconv.2.dylib']
}
}],
['OS=="win"', {
Expand All @@ -71,6 +105,43 @@
},

"conditions": [
['OS=="mac"', {
'targets+': [
{
"target_name": "build_libiconv",
"target_type": "none",
"actions": [
{
"action_name": "Run script",
"message": "Building GNU libiconv...",
"inputs": [],
"outputs": ["ext"],
"action": [
"bash",
"script/fetch-libiconv-61.sh"
]
}
]
}
# {
# "target_name": "find_libiconv",
# "target_type": "none",
# "actions": [
# {
# "action_name": "Run script",
# "message": "Locating GNU libiconv...",
# "inputs": [],
# "outputs": ["vendor/libiconv/lib/libiconv.2.dylib"],
# "action": [
# "bash",
# "script/find-gnu-libiconv.sh"
# ]
# }
# ]
# }
]
}],

# If --tests is passed to node-gyp configure, we'll build a standalone
# executable that runs tests on the patch.
['tests != 0', {
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ if (process.env.SUPERSTRING_USE_BROWSER_VERSION) {
}

TextBuffer.prototype.baseTextMatchesFile = function (source, encoding = 'UTF8') {
encoding = normalizeEncoding(encoding)

return new Promise((resolve, reject) => {
const callback = (error, result) => {
if (error) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build:node": "node-gyp rebuild",
"build:browser": "script/build-browser-version.sh",
"build": "npm run build:node && npm run build:browser",
"test:native": "script/test-native.js",
"test:native": "node ./script/test-native.js",
"test:node": "mocha test/js/*.js",
"test:browser": "SUPERSTRING_USE_BROWSER_VERSION=1 mocha test/js/*.js",
"test": "npm run test:node && npm run test:browser",
Expand Down
Loading
Loading