Skip to content

Commit f1066d6

Browse files
committed
feat(windows): add support to work with the default suite
1 parent 1d97949 commit f1066d6

File tree

8 files changed

+31
-8
lines changed

8 files changed

+31
-8
lines changed

node/config/environ.sls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{%- from tplroot ~ "/map.jinja" import node with context %}
77
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
88
9-
{%- if 'environ' in node and node.environ %}
9+
{%- if 'environ' in node and node.environ and grains.os_family != 'Windows' %}
1010
1111
{%- if node.pkg.use_upstream_source %}
1212
{%- set sls_package_install = tplroot ~ '.source.install' %}

node/config/file.sls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ node-config-npmrc-file-managed-config_file:
2424
lookup='node-config-file-file-managed-config_file'
2525
)
2626
}}
27+
{%- if grains.os_family != 'Windows' %}
2728
- mode: 640
2829
- user: {{ node.rootuser }}
2930
- group: {{ node.rootgroup }}
31+
{%- endif %}
3032
- makedirs: True
3133
- template: jinja
3234
- context:

node/init.sls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{%- set tplroot = tpldir.split('/')[0] %}
66
{%- from tplroot ~ "/map.jinja" import node with context %}
77
8-
{%- if grains.os_family not in ('Windows', 'MacOS',) %}
8+
{%- if grains.os_family not in ('MacOS',) %}
99
{%- set p = node.pkg %}
1010
1111
include:

node/osfamilymap.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ OpenBSD:
8484
Solaris: {}
8585

8686
Windows:
87+
config_file: C:\Program Files\nodejs\node_modules\npm\npmrc
88+
config:
89+
prefix: '${APPDATA}\\npm'
8790
pkg:
91+
name: node.js
8892
source:
8993
# win-x64/node.exe
9094
source_hash: 7fca04f83b0e2169e41b2e1845e8da0f07d66cf9c3a1b4150767bf3ffddccf62
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# frozen_string_literal: true
22

33
# Overide by Platform
4+
npmrc_file, config_prefix =
5+
case platform[:family]
6+
when 'windows'
7+
['C:\\Program Files\\nodejs\\node_modules\\npm\\npmrc', '${APPDATA}\\npm']
8+
else
9+
%w[/etc/npmrc /home/vagrant/.npm-packages]
10+
end
11+
412
root_group =
513
case platform[:family]
614
when 'bsd'
@@ -12,11 +20,13 @@
1220
control 'node configuration' do
1321
title 'should match desired lines'
1422

15-
describe file('/etc/npmrc') do
23+
describe file(npmrc_file) do
1624
it { should be_file }
17-
it { should be_owned_by 'root' }
18-
it { should be_grouped_into root_group }
19-
its('mode') { should cmp '0640' }
20-
its('content') { should include 'prefix = /home/vagrant/.npm-packages' }
25+
unless %w[windows].include?(platform[:family])
26+
it { should be_owned_by 'root' }
27+
it { should be_grouped_into root_group }
28+
its('mode') { should cmp '0640' }
29+
end
30+
its('content') { should include "prefix = #{config_prefix}" }
2131
end
2232
end

test/integration/default/controls/environ_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
control 'node configuration environment' do
1313
title 'should match desired lines'
1414

15+
only_if('Environment file not managed on Windows') do
16+
!%w[windows].include?(system.platform[:name])
17+
end
18+
1519
describe file('/etc/default/node.sh') do
1620
it { should be_file }
1721
it { should be_owned_by 'root' }

test/integration/default/controls/packages_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
else
2121
'nodejs'
2222
end
23+
when 'windows'
24+
'node.js'
2325
else
2426
'nodejs'
2527
end

test/salt/pillar/default.sls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
node:
55
version: 16.13.0
66
config:
7-
prefix: '/home/vagrant/.npm-packages'
7+
# yamllint disable-line rule:line-length
8+
prefix: '{{ "${APPDATA}\\npm" if grains.os == "Windows" else "/home/vagrant/.npm-packages" }}'
89
environ:
910
a: b
1011
pkg:

0 commit comments

Comments
 (0)